Skip to content
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

Throw DataCloneError if SAB cannot be cloned #781

Merged
merged 1 commit into from
Sep 18, 2021
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
7 changes: 5 additions & 2 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2551,8 +2551,11 @@ struct v8__ValueSerializer__Delegate : public v8::ValueSerializer::Delegate {
v8::Local<v8::SharedArrayBuffer> shared_array_buffer) override {
uint32_t result = 0;
if (!v8__ValueSerializer__Delegate__GetSharedArrayBufferId(
this, isolate, shared_array_buffer, &result))
return v8::Nothing<uint32_t>();
this, isolate, shared_array_buffer, &result)) {
// Forward to the original method. It'll throw DataCloneError.
return v8::ValueSerializer::Delegate::GetSharedArrayBufferId(
isolate, shared_array_buffer);
}
return v8::Just(result);
}

Expand Down
8 changes: 6 additions & 2 deletions tests/test_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4723,8 +4723,12 @@ fn value_serializer_not_implemented() {
assert!(scope.stack_trace().is_some());
assert!(scope.message().is_some());
assert_eq!(
scope.message().unwrap().get(scope).to_rust_string_lossy(scope),
"Uncaught Error: Deno serializer: get_shared_array_buffer_id not implemented"
scope
.message()
.unwrap()
.get(scope)
.to_rust_string_lossy(scope),
"Uncaught Error: #<SharedArrayBuffer> could not be cloned."
);
}

Expand Down