@vitest/web-worker 4.0.14 → 4.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/pure.js +5 -1
  2. package/package.json +2 -2
package/dist/pure.js CHANGED
@@ -315,10 +315,14 @@ function createClonedMessageEvent(data, transferOrOptions, clone) {
315
315
  debug("clone worker message %o", data);
316
316
  const origin = typeof location === "undefined" ? undefined : location.origin;
317
317
  const ports = transfer?.filter((t) => t instanceof MessagePort);
318
+ const transferWithoutPorts = transfer?.filter(
319
+ // `ports` must be excluded from the `transfer` option passed to `structuredClone` to keep the MessagePort objects working correctly in the same thread.
320
+ (t) => !(t instanceof MessagePort)
321
+ );
318
322
  if (typeof structuredClone === "function" && clone === "native") {
319
323
  debug("create message event, using native structured clone");
320
324
  return new MessageEvent("message", {
321
- data: structuredClone(data, { transfer }),
325
+ data: structuredClone(data, { transfer: transferWithoutPorts }),
322
326
  origin,
323
327
  ports
324
328
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/web-worker",
3
3
  "type": "module",
4
- "version": "4.0.14",
4
+ "version": "4.0.16",
5
5
  "description": "Web Worker support for testing in Vitest",
6
6
  "license": "MIT",
7
7
  "funding": "https://opencollective.com/vitest",
@@ -33,7 +33,7 @@
33
33
  "dist"
34
34
  ],
35
35
  "peerDependencies": {
36
- "vitest": "4.0.14"
36
+ "vitest": "4.0.16"
37
37
  },
38
38
  "dependencies": {
39
39
  "obug": "^2.1.1"