|
| 1 | +import buffer from 'node:buffer' |
| 2 | +import { readFileSync } from 'node:fs' |
1 | 3 | import { join } from 'node:path' |
2 | | -import { runInThisContext } from 'node:vm' |
| 4 | +import { setFlagsFromString } from 'node:v8' |
| 5 | +import { runInNewContext, runInThisContext } from 'node:vm' |
3 | 6 | import { parentPort, workerData } from 'node:worker_threads' |
4 | | -import { readFileSync } from 'node:fs' |
5 | | -import buffer from 'node:buffer' |
6 | 7 | import { |
7 | | - setGlobalOrigin, |
8 | | - Response, |
9 | | - Request, |
10 | | - fetch, |
11 | | - FormData, |
12 | | - File, |
13 | | - Headers, |
14 | | - FileReader |
| 8 | + fetch, File, FileReader, FormData, Headers, Request, Response, setGlobalOrigin |
15 | 9 | } from '../../../../index.js' |
16 | | -import { WebSocket } from '../../../../lib/websocket/websocket.js' |
17 | 10 | import { CloseEvent } from '../../../../lib/websocket/events.js' |
| 11 | +import { WebSocket } from '../../../../lib/websocket/websocket.js' |
18 | 12 |
|
19 | 13 | const { initScripts, meta, test, url, path } = workerData |
20 | 14 |
|
@@ -142,5 +136,10 @@ for (const script of meta.scripts) { |
142 | 136 | runInThisContext(script) |
143 | 137 | } |
144 | 138 |
|
| 139 | +// A few tests require gc, which can't be passed to a Worker. |
| 140 | +// see https://github.com/nodejs/node/issues/16595#issuecomment-340288680 |
| 141 | +setFlagsFromString('--expose-gc') |
| 142 | +globalThis.gc = runInNewContext('gc') |
| 143 | + |
145 | 144 | // Finally, run the test. |
146 | 145 | runInThisContext(test) |
0 commit comments