We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b3fcd1a commit bcd8064Copy full SHA for bcd8064
test/test-worker-imports.js
@@ -0,0 +1,19 @@
1
+// Test for thread-safety issues caused by subsequent imports of the module
2
+// in worker threads: https://github.com/mscdex/ssh2/issues/1393.
3
+// Each subsequent worker increases probability of abnormal termination.
4
+// The probability of a false pass due to zero response becomes negligible
5
+// for 4 consecutive workers.
6
+'use strict';
7
+
8
+const { Worker, isMainThread } = require('worker_threads');
9
+require('../lib/index.js');
10
11
+if (isMainThread) {
12
+ async function runWorker() {
13
+ return new Promise((r) => new Worker(__filename).on("exit", r));
14
+ }
15
+ runWorker()
16
+ .then(runWorker)
17
18
+ .then(runWorker);
19
+}
0 commit comments