Open AlgorithmAiden opened 1 week ago
bun install ws
in the folder.bun crash.js
.http://localhost:3000/
.import { spawn } from 'bun'
function update() {
process.stdout.write(`*`)
spawn({
cmd: ['bun', 'server.js']
}).exited.then(() =>
setTimeout(update, Math.random() * 1000)
)
}
update()
import { serve, file } from 'bun'
import { WebSocketServer } from 'ws'
const wss = new WebSocketServer({ port: 3001 })
setTimeout(() => wss.clients.forEach(client => {
if (client.readyState === 1) client.send('reload')
}), 100)
serve({
async fetch() {
return new Response(file('index.html'), {
headers: { 'Content-Type': 'text/html' }
})
}
})
setTimeout(process.exit, Math.random() * 1000)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
function setupWebSocket() {
new WebSocket('ws://localhost:3001').onmessage = (event) => {
if (event.data === 'reload') location.reload()
}
setTimeout(setupWebSocket, 100)
}
setupWebSocket()
</script>
</body>
</html>
How can we reproduce the crash?
Download this git repo
https://github.com/AlgorithmAiden/bun_crash_code
, then remove the .git folder from the outer folder.First change all occurrences of
process.chdir('C:\\Users\\jack\\Home\\Programming\\blog projects\\blog generator')
so that the path is the location of the folder.Run
bun livePreview.js
, after a small delay you should get an output like this: [⟍] LIVE PREVIEW [⟋] Hosting site at http://localhost:3000/ There are 0 connected websockets for live previewing Watching 1 post: Making a custom blogOpen the site at the url, the third line should now read
There is 1 connected websocket for live previewing
. CTRL+c to stop the program, then run it again after > ~250ms, it should produce the crash, sometimes this process needs to be run more than once to get the crash.Relevant log output
Stack Trace (bun.report)
Bun v1.1.15 (
b23ba1f
) on windows x86_64 [AutoCommand]panic: Internal assertion failure
debug.zig:373
:panicExtra
debug.zig:348
:panic
output.zig:363
:panic
bun.zig:3260
:assertionFailure
js_ast.zig:3117
:assert
ReadFile.zig:588
:finalize
ReadFile.zig:795
:onRead
uv__work_done
??
uv_run