-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: correct WebAssembly.instantiate callback signature in module-wrapper #9720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix: correct WebAssembly.instantiate callback signature in module-wrapper #9720
Conversation
|
CC @kgryte what do u feel about it ? |
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
modeled the new tests on existing WASM module tests |
| }); | ||
|
|
||
| // TODO: add tests | ||
| tape( 'the `initialize` method properly sets `_module` and `_instance` properties', opts, function test( t ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we wouldn't be checking for private properties. Those are implementation details. I suggest removing all private property checks here and below.
| } | ||
| }); | ||
|
|
||
| tape( 'the `exports` property returns instance exports after initialization', opts, function test( t ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a valid approach to ensure that initialization works as expected.
kgryte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let initial comments.
Description
Related Issues
This pull request has no related issues.
Bug Impact
The bug caused
this._instanceto beundefinedafter async initialization, breaking all WebAssembly operations that depend on instance exports. Any code usinginitialize()orinitializeAsync()would fail when trying to accessthis._instance.exports.*.Technical Details
The
WebAssembly.instantiate()API returnsPromise<{module: WebAssembly.Module, instance: WebAssembly.Instance}>. The previous implementation incorrectly destructured this as two separate parameters in the Promise.then()callback, which only receives a single argument.Testing
All new tests pass and verify:
_moduleand_instanceare correctly set after initializationWebAssembly.ModuleandWebAssembly.Instancerespectivelyexportsproperty is accessible after initializationChecklist
AI Assistance
@stdlib-js/reviewers