Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/core/src/host/v8/syscall/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ModuleHookKey {
}

/// Context embedder slot holding the receiver (`this`) value used for hook calls.
const RECV_SLOT_INDEX: i32 = ModuleHookKey::SenderErrorClass as i32 + 1;
pub(super) const RECV_SLOT_INDEX: i32 = ModuleHookKey::SenderErrorClass as i32 + 1;

/// Holds the `AbiVersion` used by the module
/// and the module hooks registered by the module
Expand Down
5 changes: 5 additions & 0 deletions crates/core/src/host/v8/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ pub(super) fn get_hooks<'scope>(
scope: &mut PinScope<'scope, '_>,
exports_obj: Local<'_, v8::Object>,
) -> Result<Option<HookFunctions<'scope>>, ErrorOrException<ExceptionThrown>> {
// We only set RECV_SLOT_INDEX in set_registered_hooks, which is only called in
// the v2 code path. Set it to undefined ahead of time so it's not a garbage value.
scope
.get_current_context()
.set_embedder_data(hooks::RECV_SLOT_INDEX, v8::undefined(scope).into());
if let Some(hooks) = get_registered_hooks(scope) {
return Ok(Some(hooks));
}
Expand Down
Loading