0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/lib/worker_threads.js
Chengzhong Wu 64549731b6
src: throw DataCloneError on transfering untransferable objects
The HTML StructuredSerializeWithTransfer algorithm defines that when
an untransferable object is in the transfer list, a DataCloneError is
thrown.
An array buffer that is already transferred is also considered as
untransferable.

PR-URL: https://github.com/nodejs/node/pull/47604
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-05-05 11:22:42 +00:00

44 lines
743 B
JavaScript

'use strict';
const {
isMainThread,
SHARE_ENV,
resourceLimits,
setEnvironmentData,
getEnvironmentData,
threadId,
Worker,
} = require('internal/worker');
const {
MessagePort,
MessageChannel,
moveMessagePortToContext,
receiveMessageOnPort,
BroadcastChannel,
} = require('internal/worker/io');
const {
markAsUntransferable,
isMarkedAsUntransferable,
} = require('internal/buffer');
module.exports = {
isMainThread,
MessagePort,
MessageChannel,
markAsUntransferable,
isMarkedAsUntransferable,
moveMessagePortToContext,
receiveMessageOnPort,
resourceLimits,
threadId,
SHARE_ENV,
Worker,
parentPort: null,
workerData: null,
BroadcastChannel,
setEnvironmentData,
getEnvironmentData,
};