Closed m4r1vs closed 3 weeks ago
If your environment has node.js installed, bun run build
will run rsbuild with node.js instead of bun itself as there's a shebang refer to node in rsbuild's cli. that's why it works outside the docker.
const rspack = require('@rspack/core');
rspack({ mode: 'none' }).run((err) => console.log({err}));
running it via bun, the process will keep running after internally called instance.build()
, even outside docker.
// rspack.config.js
module.exports = {
plugins: [
{
apply(compiler) {
compiler.hooks.done.tap("quit", () => {
if (typeof Bun !== 'undefined') {
process.exit(process.exitCode || 0);
})
});
},
},
],
};
export default defineConfig({
// ...
plugins: [
{
setup: (api) => {
api.onAfterBuild(({ isFirstCompile, stats }) => {
if (typeof Bun !== 'undefined') {
process.exit(process.exitCode || 0);
}
});
},
},
],
// ...
})
@xc2 seems bun's compatible issue?
@xc2 seems bun's compatible issue?
@hardfist yes, seems like bun's napi implementation problem. still not find out the rspack code that causes bun hanging
If your environment has node.js installed,
bun run build
will run rsbuild with node.js instead of bun itself as there's a shebang refer to node in rsbuild's cli. that's why it works outside the docker.a smaller reproduce
const rspack = require('@rspack/core'); rspack({ mode: 'none' }).run((err) => console.log({err}));
running it via bun, the process will keep running after internally called
instance.build()
, even outside docker.How to escape
rspack
// rspack.config.js module.exports = { plugins: [ { apply(compiler) { compiler.hooks.done.tap("quit", () => { if (typeof Bun !== 'undefined') { process.exit(process.exitCode || 0); }) }); }, }, ], };
rsbuild
export default defineConfig({ // ... plugins: [ { setup: (api) => { api.onAfterBuild(({ isFirstCompile, stats }) => { if (typeof Bun !== 'undefined') { process.exit(process.exitCode || 0); } }); }, }, ], // ... })
Thank you! Installing nodejs with alpine package manager fixed this issue. Cheers!:)
close since seem this issue is fixed
System Info
Docker images tested: fedora:latest, oven/bun:1, oven/bun:debian, oven/bun:alpine. All on linux/amd64.
Details
When running
bun run build
which invokesrsbuild build
, the project (a TypeScript React app created withbun create rsbuild@latest
) is built correctly but the process does not exit and is stuck at the following forever:This only occurs when the command is executed within a docker container and works fine outside of docker. I will also report this at bun as I am not sure who's the one responsible for a fix.
Workaround
Currently I just send the command to the background and add a generous sleep like this:
Reproduce link
No response
Reproduce Steps
bun create rsbuild@latest
.COPY rspack-project /app/rspack-project
WORKDIR /app/rspack-project
RUN bun install RUN bun run build CMD ["echo 'never reached'"]