meteor / meteor/blaze

Errors in onCreated callback cause a complete stop for rendering further Templates

Open
#379 0 comments 0 reactions 0 assignees View on GitHub
hacktoberfest
Dominant language
JavaScript
Stars
543
Forks
117
Avg merge
6h 18m
Merged PRs (30d)
2

Description

## Reproduction

Create a new project

```bash
$ meteor create testproject --blaze
$ cd testproject && meteor
```

Then manually added `blaze@2.6.1-rc.2` (or once release `blaze@2.6.1`) to `.meteor/packages`

Then replaced `client/main.html` with the following:

```html

testproject

none
{{#each option in options}}
Template {{option}}
{{/each}}

{{#if show}}
{{> Template.dynamic template=show }}
{{/if}}

TemplateA
templateB
templateC {{raise}}
templateD raise
TemplateE


render
remove

templateF

Inner Template with Blaze.render
```

and the following code in `client/main.js`:

```js
import { Template } from 'meteor/templating'
import { ReactiveVar } from 'meteor/reactive-var'
import './main.html'
import { Blaze } from 'meteor/blaze'

Template.body.onCreated(function () {
this.show = new ReactiveVar()
})

Template.body.helpers({
show () {
return Template.instance().show.get()
},
options () {
return [...'ABCDEF']
}
})

Template.body.events({
'click .remove-btn' () {
Blaze.remove(renderedView)
},
'change .select-template' (event, templateInstance) {
const value = templateInstance.$(event.currentTarget).val()
templateInstance.show.set(value)
}
})

Template.templateA.onCreated(function () {
throw new Error('Error-1')
})

Template.templateB.onRendered(function () {
throw new Error('Error-2')
})

Template.templateC.helpers({
raise () {
throw new Error('Error-3')
}
})

Template.templateD.events({
'click .raise-btn' () {
throw new Error('Error-4')
}
})

let renderedView

Template.templateE.events({
'click .render-btn' (event, templateInstance) {
const parent = templateInstance.$('#renderTarget').get(0)
renderedView = Blaze.render(Template.templateEInner, parent)
},
'click .remove-btn' (event, templatInstance) {
Blaze.remove(renderedView)
}
})

Template.templateEInner.onDestroyed(function () {
throw new Error('Error-5')
})

Template.templateF.onDestroyed(function () {
throw new Error('Error-6')
})
```

Here Are my results

## on Created - Dev

```
09:46:04.900 Exception from Tracker recompute function: meteor.js:1064:23
09:46:04.901 Error: Error-1 meteor.js:1064:23
09:46:04.901 module/

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue using the client/main.html and client/main.js examples, starting with the Blaze rendering lifecycle around onCreated, onRendered, helpers, and onDestroyed callbacks. Verify behavior for the six reported errors and the follow-up DOMRange failure; done means one callback error no longer prevents later templates from rendering or leaves removed views in a broken state.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.