ember.js icon indicating copy to clipboard operation
ember.js copied to clipboard

[5.12] Non helpful error when the function for `on` modifier was forget to add

Open mkszepp opened this issue 1 year ago • 4 comments

🐞 Describe the Bug

Beginning with ember v5.12 the error handing is not helpful when you forget to create the pass function to on modifier.

🔬 Minimal Reproduction

Create a hbs file with this content:

<div {{on "click" this.myfunction}}></div>

Minimal reproduction: https://github.com/mkszepp/ember-missing-action-function

😕 Actual Behavior

If you forget to create the function in js/ts you will get this error: Error in Firefox: Uncaught TypeError: userProvidedCallback is undefined grafik

Error in Chrome: Uncaught TypeError: Cannot read properties of undefined (reading 'bind') grafik

🤔 Expected Behavior

We should bring back better error handling like it was in <= v5.11

Uncaught Error: You must pass a function as the second argument to the `on` modifier; you passed undefined. While rendering:

this.myfunction

grafik

🌍 Environment

  • Ember: 5.12.0
  • Ember-CLI: 5.12.0
  • Node.js/pnpm: v20 / v9
  • OS: Linux / WIndows
  • Browser: Firefox / Chrome

mkszepp avatar Oct 25 '24 17:10 mkszepp

def a bug!

in your 5.11 stack, what function (and from where) prints that nicer message?

NullVoxPopuli avatar Oct 25 '24 17:10 NullVoxPopuli

error message in v5.11 comes from here: https://github.com/glimmerjs/glimmer-vm/blob/main/packages/%40glimmer/runtime/lib/modifiers/on.ts#L76

grafik

mkszepp avatar Oct 25 '24 17:10 mkszepp

i think here it was introduced the bug...

https://github.com/glimmerjs/glimmer-vm/commit/2d9fc0174e5c49f0b79736664cd4162eccd4e6a8#diff-301b4fe274bd34f5552c35fc1f58078575896ba487df721bed939eb1d0fe9891R75

mkszepp avatar Oct 25 '24 18:10 mkszepp

oofta -- that check stuff in general is supposed to be stripped during glimmer-vm publish.

thank you for finding and reporting this!!!

NullVoxPopuli avatar Oct 25 '24 18:10 NullVoxPopuli