Skip to content

Guard SIGWINCH binding on Windows (fix SIGWINCH listener in winx64 build error) #18

@afunyun

Description

@afunyun

Actual issue:

On Windows, calling Deno.addSignalListener("SIGWINCH") throws “Windows only supports SIGINT/SIGBREAK” and crashes the app at startup.

{"timestamp":"2025-05-25T12:23:36.184Z","level":"INFO","message":"LLM Adapter initialized successfully."}
{"timestamp":"2025-05-25T12:23:36.184Z","level":"INFO","message":"Initializing LLM Adapter","details":{"provider":"openai","baseURL":"","model":"o4-mini"}}
{"timestamp":"2025-05-25T12:23:36.073Z","level":"INFO","message":"Loading config file","details":{"path":".config\\unibear\\config.json"}}
{"timestamp":"2025-05-25T12:23:36.182Z","level":"WARNING","message":"Failed to load config from .config\\unibear\\config.json: The system cannot find the path specified. (os error 3): readfile '.config\\unibear\\config.json'. Using default config.","details":{"path":".config\\unibear\\config.json","error":"The system cannot find the path specified. (os error 3): readfile '.config\\unibear\\config.json'"}}
{"timestamp":"2025-05-25T12:23:36.184Z","level":"INFO","message":"LLM Provider configured: openai","details":{"config":{"baseURL":"","apiKey":"sk-proj-***","model":"o4-mini","reasoning_effort":"medium","webSearchModel":"gpt-4.1-mini"}}}
{"timestamp":"2025-05-25T12:23:36.192Z","level":"INFO","message":"Initializing server..."}
{"timestamp":"2025-05-25T12:23:36.236Z","level":"INFO","message":"Initializing UI store and dimensions"}

reproduce:

  1. Run Unibear on Windows (10 or 11).
  2. App crashes immediately with error from ext:deno_os/40_signals.js:14.

Expected Behavior:

Skip SIGWINCH when platform is Windows. App continues to load.

Actual Behavior:

Uncaught exception prevents UI from initializing. Deno crash screen which is fairly bizarre looking first time seeing it lol.

Searched the repo and only found it in one spot, src/store/main.ts#L26 @ 0d96a73

Fix: wrap the addSignalListener("SIGWINCH") call in an OS check or surround it with try/catch, or revert it to the SIGINT it seems to have been prior.

const setDimensions = () => {
  const { columns, rows } = Deno.consoleSize();
  set({ dimensions: { cols: columns, rows } });
  Logger.debug("Console dimensions updated", { columns, rows });
};
Deno.addSignalListener("SIGWINCH", setDimensions);
setDimensions();

Only place that I can see it mentioned in the code, will submit a pr prob unless y'all dislike that.

Deno info from the install script:

{
  "tasks": {
    "dev": "DEV=true deno run --watch -A src/main.ts",
    "compile": "deno compile -A -o bin/unibear src/main.ts",
    "compile-no-check": "deno compile -A --no-check -o bin/unibear src/main.ts"
  },
  "version": "0.4.0",
  "imports": {
    "ink": "npm:ink@^5.2.0",
    "react": "npm:react@^18.3.1"
  },
  "compilerOptions": {
    "types": ["./src/types.d.ts"]
  },
  "lint": {
    "rules": {
      "exclude": ["no-explicit-any"]
    }
  }
}

Image

Image

Basically seems that unibear is looking for a SIGWINCH for signal that the dimensions of the window change & it causes windows deno to crash because that shouldn't be a thing in windows.

Likely still works fine on OSX/any nix since that's much more standard there. Haven't tried on WSL yet but I will.

Image

Edit: Not broken on linux, at least WSL

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions