You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better error for performance access at Wizer time #153
That was the first thing I checked. Here is a debug build which prints debug info. I build it with npm run build:debug and then set const DEBUG_BUILD = true; to use it.
Are you trying to use performance.now() in the JS initialization outside of a component exported function? Wizer-time use of the performance global is not permitted.
// this is a wizer time use of the performance global - NOT ALLOWEDconststart=performance.now();exportconstrun={run(){console.log(performance.now()-start);}};
git clone git@github.com:cataggar/StarlingMonkey15.git --no-checkout
cd StarlingMonkey15
git checkout 4d130a9cab15563cc38a4619a3c6a8c129d1be85
cd cowsay
bun install
bun run build.ts
bunx jco componentize cowsay.js --wit src/cowsay.wit -o cowsay.wasm
Following those steps:
~/tmp/StarlingMonkey15/cowsay> bun install
bun install v1.1.33 (247456b6)
Checked 108 installs across 130 packages (no changes) [117.00ms]
~/tmp/StarlingMonkey15/cowsay> bun run build.ts
~/tmp/StarlingMonkey15/cowsay> bunx jco componentize cowsay.js --wit src/cowsay.wit -o cowsay.wasm
Redirecting call to abort() to mozalloc_abort
Error: the `componentize.wizer` function trapped
Caused by:
0: error while executing at wasm backtrace:
0: 0x25f20 - <unknown>!<wasm function 206>
1: 0x25f29 - <unknown>!<wasm function 207>
2: 0xa921 - <unknown>!<wasm function 87>
3: 0x42119 - <unknown>!<wasm function 348>
4: 0x25431f - <unknown>!<wasm function 5279>
5: 0x254f50 - <unknown>!<wasm function 5282>
6: 0x25576e - <unknown>!<wasm function 5285>
7: 0x35a029 - <unknown>!<wasm function 7091>
8: 0x258ee8 - <unknown>!<wasm function 5313>
9: 0x24bbcc - <unknown>!<wasm function 5278>
10: 0x245b22 - <unknown>!<wasm function 5276>
11: 0x255aeb - <unknown>!<wasm function 5288>
12: 0x29a0a9 - <unknown>!<wasm function 5791>
13: 0x34e9db - <unknown>!<wasm function 7049>
14: 0x34e72d - <unknown>!<wasm function 7049>
15: 0x20286 - <unknown>!<wasm function 105>
16: 0x1f50e - <unknown>!<wasm function 104>
17: 0xa882 - <unknown>!<wasm function 86>
18: 0x22580f - <unknown>!<wasm function 5012>
1: wasm trap: wasm `unreachable` instruction executed
(jco componentize) Error: Failed to initialize the compiled Wasm binary with Wizer:
Wizering failed to complete
at componentize (file:///Users/cataggar/tmp/StarlingMonkey15/node_modules/@bytecodealliance/componentize-js/src/componentize.js:271:13)
at async componentize (file:///Users/cataggar/tmp/StarlingMonkey15/node_modules/@bytecodealliance/jco/src/cmd/componentize.js:11:25)
at async file:///Users/cataggar/tmp/StarlingMonkey15/node_modules/@bytecodealliance/jco/src/jco.js:200:9
So looking at your JS code, enable() accesses performance.timeOrigin and enable() is called at Wizer time during the initialization of the application.
The bug here is that we don't throw a better error - the error should be:
Error: Cannot access `performance` properties at pre-initialization time.
The fix is to wrap all these enable() callers in a function which is only called on usage of the component, so that you aren't capturing a timeOrigin from the Wizer initialization time.
Activity
guybedford commentedon Oct 30, 2024
Check that you're definitely using the latest ComponentizeJS in your node_modules folder verifying the version.
cataggar commentedon Oct 30, 2024
That was the first thing I checked. Here is a debug build which prints debug info. I build it with
npm run build:debugand then setconst DEBUG_BUILD = true;to use it.guybedford commentedon Oct 30, 2024
Are you trying to use
performance.now()in the JS initialization outside of a component exported function? Wizer-time use of theperformanceglobal is not permitted.guybedford commentedon Oct 30, 2024
i.e. compile time is not the time to do timing stuff.
cataggar commentedon Oct 30, 2024
I have no customization like that. Happy to share my screen.
guybedford commentedon Oct 31, 2024
You're writing something like this:
when you should be writing this:
cataggar commentedon Oct 31, 2024
Here are the steps to reproduce.
Following those steps:
guybedford commentedon Oct 31, 2024
So looking at your JS code,
enable()accessesperformance.timeOriginandenable()is called at Wizer time during the initialization of the application.The bug here is that we don't throw a better error - the error should be:
The fix is to wrap all these
enable()callers in a function which is only called on usage of the component, so that you aren't capturing atimeOriginfrom the Wizer initialization time.Hope that helps.
[-]timeOrigin still not set[/-][+]Better error for `performance` access at Wizer time[/+]Cannot access performance properties at pre-initialization time.
cataggar commentedon Oct 31, 2024
It did! I'm able to disable
tryGetPerformanceHooksto avoid accessingperformance. I'm able to use yesterday's releases now.guybedford commentedon Oct 31, 2024
Great to hear, we should definitely improve the error though.