oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

Home Page:https://bun.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Watcher-Build combo sometimes crashes server

djohoe28 opened this issue · comments

How can we reproduce the crash?

Unfortunately, I haven't been able to reliably reproduce the crash...

  • VSCode 1.89.1
  • Windows Powershell 1.19.11213.0
  • bun 1.1.7

Using VSCode Terminal (Powershell), called bun run start (bun run index.tsx).
When I hit Ctrl+S (once) on one of the monitored files (./src/main.tsx - basic React & WebSocket boilerplate), Bun crashed.
EDIT: When I have been able to reproduce this error, it happened on the first Save - if the initial Save works, it seems like additional saves will not crash the server.

It was easiest (still not guaranteed) to reproduce when adding the --hot flag and removing/adding async/await to the rebuild definition / call.

Interestingly, the crash happened despite the index.tsx server code being completely unrelated to ./src/main.tsx - I even directed Watcher directly to the ./src folder, so it wouldn't monitor itself (it's handled by the --hot flag, anyway).

Hope this is of some use!

P.S.: Just to be extra thorough, I've pasted the contents of my package.json below (tsconfig.json hasn't been touched since bun init):

{
  "name": "my-app",
  "module": "index.tsx",
  "type": "module",
  "private": true,
  "scripts": {
    "start": "bun run index.tsx",
  },
  "devDependencies": {
    "@types/bun": "^1.1.2",
    "@types/react": "^18.3.2",
    "@types/react-dom": "^18.3.0"
  },
  "peerDependencies": {
    "react": "canary",
    "react-dom": "canary",
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@emotion/react": "^11.11.4",
    "@emotion/styled": "^11.11.5",
    "@mui/material": "^5.15.17",
    "timing-object": "^3.1.78",
    "timing-provider": "^7.1.16",
    "timingsrc": "^1.4.19"
  }
}

JavaScript/TypeScript code that reproduces the crash?

import { watch } from "fs";
const rebuild = async () => Bun.build({entrypoints: ["./src/main.tsx"], outdir: "./public"}); // ? Rebuild Client-side code.
const watcher = watch(`${import.meta.dir}\\src`, async (event, filename) => { console.log("Rebuilding..."); await rebuild(); });

Relevant log output

$ bun --hot run index.tsx
Rebuilding...
Rebuilding...
============================================================
Bun v1.1.7 (b0b7db5c) Windows x64
Args: "C:\Users\DJoho\.bun\bin\bun.exe", "--hot", "run", "index.tsx"
Features: jsc dotenv tsconfig 
Builtins: "bun:main" "node:fs" "node:string_decoder" "node:util/types" 
Elapsed: 1105ms | User: 0ms | Sys: 0ms
RSS: 114.78MB | Peak: 114.78MB | Commit: 0.20GB | Faults: 28267

panic(main thread): attempt to use null value
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.7/wr1b0b7db5AiogggEmx0/I__w+zl2C___w+zl2CA0eNpLLClJzS0oUSjJVygtTlXIK83JUShLzClNBQB82AmI

error: script "start" exited with code 3

Stack Trace (bun.report)

Bun v1.1.7 (b0b7db5) on windows x86_64 [RunCommand]

panic: attempt to use null value

  • Strong.zig:69: get
  • 2 unknown/js code
  • llint_entry
  • 3 unknown/js code
  • llint_entry