Repository navigation
fix(core): stop the bind setTimeout from shadowing the global one - #82
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
The PR renames the core's setTimeout function to setExecTimeout to prevent shadowing the global setTimeout in the Emscripten glue scope, updates Module.setTimeout to maintain the API, and adds a test to ensure no top-level function in bind.js shadows a global. This fixes the issue where Emscripten's timers (like poll and async callbacks) would call the core's ineffective setTimeout instead of the global one, causing timers to not fire.
review-bot, model nvidia/nemotron-3-super-120b-a12b:free, verdict approve
What
Renames the core glue's
function setTimeout(timeout)insrc/bind/ffmpeg/bind.jstosetExecTimeout.Module.setTimeoutkeeps its name, so the API does not change. A Node test checks that no top-level function inbind.jsis named like a global.Why
bind.jsis linked as pre-js, so it shares a scope with Emscripten's glue. The built core shows thatsafeSetTimeout(async callbacks) and___syscall_pollcallsetTimeout(...), and they got ours. Ours stores its first argument inModule.timeoutand schedules nothing. A timer the glue sets never fires, and the nextexec()can pick up a function as its timeout. This is upstream ffmpegwasm#611, found while porting upstream's regression tests in #81.Testing
I ran the new check by hand against master's
bind.js, where it reportssetTimeout, and against this branch, where it reports nothing. Not run locally: the core build and the rest of the tests, which only run in CI.Noticed, not fixed
bind.jsandtests/ffmpeg-node.test.mjsalready failprettier --checkon master.