mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
fix: check if BroadcastChannel is open before sending (#17366)
Fixes #16978
This commit is contained in:
parent
658fac6e86
commit
b851b3ab74
2 changed files with 12 additions and 2 deletions
|
@ -2,7 +2,7 @@
|
||||||
import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
|
import { assertEquals } from "../../../test_util/std/testing/asserts.ts";
|
||||||
import { deferred } from "../../../test_util/std/async/deferred.ts";
|
import { deferred } from "../../../test_util/std/async/deferred.ts";
|
||||||
|
|
||||||
Deno.test("broadcastchannel worker", async () => {
|
Deno.test("BroadcastChannel worker", async () => {
|
||||||
const intercom = new BroadcastChannel("intercom");
|
const intercom = new BroadcastChannel("intercom");
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
|
@ -27,3 +27,9 @@ Deno.test("broadcastchannel worker", async () => {
|
||||||
|
|
||||||
await promise;
|
await promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("BroadcastChannel immediate close after post", () => {
|
||||||
|
const bc = new BroadcastChannel("internal_notification");
|
||||||
|
bc.postMessage("New listening connected!");
|
||||||
|
bc.close();
|
||||||
|
});
|
||||||
|
|
|
@ -122,7 +122,11 @@
|
||||||
dispatch(this, this[_name], new Uint8Array(data));
|
dispatch(this, this[_name], new Uint8Array(data));
|
||||||
|
|
||||||
// Send to listeners in other VMs.
|
// Send to listeners in other VMs.
|
||||||
defer(() => core.opAsync("op_broadcast_send", rid, this[_name], data));
|
defer(() => {
|
||||||
|
if (!this[_closed]) {
|
||||||
|
core.opAsync("op_broadcast_send", rid, this[_name], data);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
|
Loading…
Reference in a new issue