Skip to content

[Bug]: v10 new crash if $BROWSER points to .sh script (e.g. Codespaces) #32949

@aaronadamsCA

Description

@aaronadamsCA

Describe the bug

Since upgrading to v10, Storybook is crashing on startup:

node:events:486
      throw er; // Unhandled 'error' event
      ^

Error: spawn xdg-open ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',
  spawnargs: [ 'http://localhost:6022/' ]

I can work around it with --no-open, but ideally that wouldn't be necessary.

What I've managed to work out so far:

  • My $BROWSER value points to a shell script (ends with .sh), so $BROWSER http://localhost:6022/ opens the local browser.
  • xdg-open is not available in default container images. I could install it in our images, but that's a lot of bloat just to open a browser.
  • v10 did change the browser opening code. It looks like the value of $BROWSER is ignored unless it ends with .js, which ours does not.
  • When I compared this to the Vite browser opening code, which works fine for us, I found it also has a .js extension check. So I can't actually explain the difference in behaviour.

Reproduction link

Just use storybook.new, then open in Codespaces (or any environment with $BROWSER pointing to a shell script and xdg-open not installed).

Reproduction steps

No response

System

System:
    OS: Linux 6.8 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (4) x64 AMD EPYC 7763 64-Core Processor
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.11.0 - ~/.volta/tools/image/node/24.11.0/bin/node
    Yarn: 4.9.4 - ~/.volta/tools/image/yarn/4.9.4/bin/yarn
    npm: 11.6.1 - ~/.volta/tools/image/node/24.11.0/bin/npm
    pnpm: 10.20.0 - ~/.volta/tools/image/pnpm/10.20.0/bin/pnpm <----- active
  npmPackages:
    @storybook/addon-a11y: catalog: => 10.0.2 
    @storybook/addon-docs: catalog: => 10.0.2 
    @storybook/addon-vitest: catalog: => 10.0.2 
    @storybook/react-vite: catalog: => 10.0.2 
    storybook: catalog: => 10.0.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions