Piscina & tinypool hang, workerpool hangs with child_process and returns but prints errors with threads.
Last active
May 29, 2025 17:06
-
-
Save spiffytech/45e3d3ecd3c46c1ef773ec0e2d073be3 to your computer and use it in GitHub Desktop.
Bun worker threads libraries repros
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"lockfileVersion": 1, | |
"workspaces": { | |
"": { | |
"name": "worker-test", | |
"dependencies": { | |
"piscina": "^5.0.0", | |
"tinypool": "^1.0.2", | |
"workerpool": "^9.3.2", | |
}, | |
"devDependencies": { | |
"@types/bun": "latest", | |
}, | |
"peerDependencies": { | |
"typescript": "^5", | |
}, | |
}, | |
}, | |
"packages": { | |
"@napi-rs/nice": ["@napi-rs/[email protected]", "", { "optionalDependencies": { "@napi-rs/nice-android-arm-eabi": "1.0.1", "@napi-rs/nice-android-arm64": "1.0.1", "@napi-rs/nice-darwin-arm64": "1.0.1", "@napi-rs/nice-darwin-x64": "1.0.1", "@napi-rs/nice-freebsd-x64": "1.0.1", "@napi-rs/nice-linux-arm-gnueabihf": "1.0.1", "@napi-rs/nice-linux-arm64-gnu": "1.0.1", "@napi-rs/nice-linux-arm64-musl": "1.0.1", "@napi-rs/nice-linux-ppc64-gnu": "1.0.1", "@napi-rs/nice-linux-riscv64-gnu": "1.0.1", "@napi-rs/nice-linux-s390x-gnu": "1.0.1", "@napi-rs/nice-linux-x64-gnu": "1.0.1", "@napi-rs/nice-linux-x64-musl": "1.0.1", "@napi-rs/nice-win32-arm64-msvc": "1.0.1", "@napi-rs/nice-win32-ia32-msvc": "1.0.1", "@napi-rs/nice-win32-x64-msvc": "1.0.1" } }, "sha512-zM0mVWSXE0a0h9aKACLwKmD6nHcRiKrPpCfvaKqG1CqDEyjEawId0ocXxVzPMCAm6kkWr2P025msfxXEnt8UGQ=="], | |
"@napi-rs/nice-android-arm-eabi": ["@napi-rs/[email protected]", "", { "os": "android", "cpu": "arm" }, "sha512-5qpvOu5IGwDo7MEKVqqyAxF90I6aLj4n07OzpARdgDRfz8UbBztTByBp0RC59r3J1Ij8uzYi6jI7r5Lws7nn6w=="], | |
"@napi-rs/nice-android-arm64": ["@napi-rs/[email protected]", "", { "os": "android", "cpu": "arm64" }, "sha512-GqvXL0P8fZ+mQqG1g0o4AO9hJjQaeYG84FRfZaYjyJtZZZcMjXW5TwkL8Y8UApheJgyE13TQ4YNUssQaTgTyvA=="], | |
"@napi-rs/nice-darwin-arm64": ["@napi-rs/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-91k3HEqUl2fsrz/sKkuEkscj6EAj3/eZNCLqzD2AA0TtVbkQi8nqxZCZDMkfklULmxLkMxuUdKe7RvG/T6s2AA=="], | |
"@napi-rs/nice-darwin-x64": ["@napi-rs/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-jXnMleYSIR/+TAN/p5u+NkCA7yidgswx5ftqzXdD5wgy/hNR92oerTXHc0jrlBisbd7DpzoaGY4cFD7Sm5GlgQ=="], | |
"@napi-rs/nice-freebsd-x64": ["@napi-rs/[email protected]", "", { "os": "freebsd", "cpu": "x64" }, "sha512-j+iJ/ezONXRQsVIB/FJfwjeQXX7A2tf3gEXs4WUGFrJjpe/z2KB7sOv6zpkm08PofF36C9S7wTNuzHZ/Iiccfw=="], | |
"@napi-rs/nice-linux-arm-gnueabihf": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "arm" }, "sha512-G8RgJ8FYXYkkSGQwywAUh84m946UTn6l03/vmEXBYNJxQJcD+I3B3k5jmjFG/OPiU8DfvxutOP8bi+F89MCV7Q=="], | |
"@napi-rs/nice-linux-arm64-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-IMDak59/W5JSab1oZvmNbrms3mHqcreaCeClUjwlwDr0m3BoR09ZiN8cKFBzuSlXgRdZ4PNqCYNeGQv7YMTjuA=="], | |
"@napi-rs/nice-linux-arm64-musl": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-wG8fa2VKuWM4CfjOjjRX9YLIbysSVV1S3Kgm2Fnc67ap/soHBeYZa6AGMeR5BJAylYRjnoVOzV19Cmkco3QEPw=="], | |
"@napi-rs/nice-linux-ppc64-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "ppc64" }, "sha512-lxQ9WrBf0IlNTCA9oS2jg/iAjQyTI6JHzABV664LLrLA/SIdD+I1i3Mjf7TsnoUbgopBcCuDztVLfJ0q9ubf6Q=="], | |
"@napi-rs/nice-linux-riscv64-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "none" }, "sha512-3xs69dO8WSWBb13KBVex+yvxmUeEsdWexxibqskzoKaWx9AIqkMbWmE2npkazJoopPKX2ULKd8Fm9veEn0g4Ig=="], | |
"@napi-rs/nice-linux-s390x-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "s390x" }, "sha512-lMFI3i9rlW7hgToyAzTaEybQYGbQHDrpRkg+1gJWEpH0PLAQoZ8jiY0IzakLfNWnVda1eTYYlxxFYzW8Rqczkg=="], | |
"@napi-rs/nice-linux-x64-gnu": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-XQAJs7DRN2GpLN6Fb+ZdGFeYZDdGl2Fn3TmFlqEL5JorgWKrQGRUrpGKbgZ25UeZPILuTKJ+OowG2avN8mThBA=="], | |
"@napi-rs/nice-linux-x64-musl": ["@napi-rs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-/rodHpRSgiI9o1faq9SZOp/o2QkKQg7T+DK0R5AkbnI/YxvAIEHf2cngjYzLMQSQgUhxym+LFr+UGZx4vK4QdQ=="], | |
"@napi-rs/nice-win32-arm64-msvc": ["@napi-rs/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-rEcz9vZymaCB3OqEXoHnp9YViLct8ugF+6uO5McifTedjq4QMQs3DHz35xBEGhH3gJWEsXMUbzazkz5KNM5YUg=="], | |
"@napi-rs/nice-win32-ia32-msvc": ["@napi-rs/[email protected]", "", { "os": "win32", "cpu": "ia32" }, "sha512-t7eBAyPUrWL8su3gDxw9xxxqNwZzAqKo0Szv3IjVQd1GpXXVkb6vBBQUuxfIYaXMzZLwlxRQ7uzM2vdUE9ULGw=="], | |
"@napi-rs/nice-win32-x64-msvc": ["@napi-rs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-JlF+uDcatt3St2ntBG8H02F1mM45i5SF9W+bIKiReVE6wiy3o16oBP/yxt+RZ+N6LbCImJXJ6bXNO2kn9AXicg=="], | |
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.2.15" } }, "sha512-U1ljPdBEphF0nw1MIk0hI7kPg7dFdPyM7EenHsp6W5loNHl7zqy6JQf/RKCgnUn2KDzUpkBwHPnEJEjII594bA=="], | |
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-w9CZGm9RDjzTh/D+hFwlBJ3ziUaVw7oufKA3vOFSOZlzmW9AkZnfjPb+DLnrV6qtgL/LNmP0/2zBNCFHL3F0ng=="], | |
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-NarRIaS+iOaQU1JPfyKhZm4AsUOrwUOqRNHY0XxI8GI8jYxiLXLcdjYMG9UKS+fwWasc1uw1htV9AX24dD+p4w=="], | |
"piscina": ["[email protected]", "", { "optionalDependencies": { "@napi-rs/nice": "^1.0.1" } }, "sha512-R+arufwL7sZvGjAhSMK3TfH55YdGOqhpKXkcwQJr432AAnJX/xxX19PA4QisrmJ+BTTfZVggaz6HexbkQq1l1Q=="], | |
"tinypool": ["[email protected]", "", {}, "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA=="], | |
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ=="], | |
"undici-types": ["[email protected]", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="], | |
"workerpool": ["[email protected]", "", {}, "sha512-Xz4Nm9c+LiBHhDR5bDLnNzmj6+5F+cyEAWPMkbs2awq/dYazR/efelZzUAjB/y3kNHL+uzkHvxVVpaOfGCPV7A=="], | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "worker-test", | |
"type": "module", | |
"private": true, | |
"scripts": { | |
"piscina": "bun run piscina-main.ts", | |
"tinypool": "bun run tinypool-main.ts", | |
"workerpool-threads": "bun run workerpool-threads.js", | |
"workerpool-childprocess": "bun run workerpool-childprocess.js" | |
}, | |
"devDependencies": { | |
"@types/bun": "latest" | |
}, | |
"peerDependencies": { | |
"typescript": "^5" | |
}, | |
"dependencies": { | |
"piscina": "^5.0.0", | |
"tinypool": "^1.0.2", | |
"workerpool": "^9.3.2" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const Piscina = require("piscina"); | |
const piscina = new Piscina({ | |
filename: path.resolve(__dirname, "piscina-worker.js"), | |
}); | |
(async function () { | |
console.log("Calling"); | |
const result = await piscina.run({ a: 4, b: 6 }); | |
console.log("Call finished"); | |
console.log(result); // Prints 10 | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = ({ a, b }) => { | |
console.log("Worker called"); | |
return a + b; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Tinypool from "tinypool"; | |
const pool = new Tinypool({ | |
filename: new URL("./tinypool-worker.js", import.meta.url).href, | |
}); | |
console.log("Calling"); | |
const result = await pool.run({ a: 4, b: 6 }); | |
console.log("Call finished"); | |
console.log(result); // Prints 10 | |
// Make sure to destroy pool once it's not needed anymore | |
// This terminates all pool's idle workers | |
await pool.destroy(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ({ a, b }) => { | |
console.log("Worker called"); | |
return a + b; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
// Environment setup & latest features | |
"lib": ["ESNext"], | |
"target": "ESNext", | |
"module": "Preserve", | |
"moduleDetection": "force", | |
"jsx": "react-jsx", | |
"allowJs": true, | |
// Bundler mode | |
"moduleResolution": "bundler", | |
"allowImportingTsExtensions": true, | |
"verbatimModuleSyntax": true, | |
"noEmit": true, | |
// Best practices | |
"strict": true, | |
"skipLibCheck": true, | |
"noFallthroughCasesInSwitch": true, | |
"noUncheckedIndexedAccess": true, | |
"noImplicitOverride": true, | |
// Some stricter flags (disabled by default) | |
"noUnusedLocals": false, | |
"noUnusedParameters": false, | |
"noPropertyAccessFromIndexSignature": false | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const workerpool = require("workerpool"); | |
const pool = workerpool.pool({ workerType: "process" }); | |
function add(a, b) { | |
console.log("Worker called"); | |
return a + b; | |
} | |
pool | |
.exec(add, [3, 4]) | |
.then(function (result) { | |
console.log("result", result); // outputs 7 | |
}) | |
.catch(function (err) { | |
console.error(err); | |
}) | |
.then(function () { | |
pool.terminate(); // terminate all workers when done | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const workerpool = require("workerpool"); | |
const pool = workerpool.pool(); | |
function add(a, b) { | |
console.log("Worker called"); | |
return a + b; | |
} | |
pool | |
.exec(add, [3, 4]) | |
.then(function (result) { | |
console.log("result", result); // outputs 7 | |
}) | |
.catch(function (err) { | |
console.error(err); | |
}) | |
.then(function () { | |
pool.terminate(); // terminate all workers when done | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment