Skip to content

Nitro v3 alpha 2 breaks CommonJS packages with Bare runtime detection (end-of-stream, duplexify) #3972

@WebCloud

Description

@WebCloud

Environment

  • nitro: 3.0.1-alpha.2
  • Runtime: Bun 1.3.5
  • Framework: TanStack Start
  • Affected packages: end-of-stream@1.4.5, duplexify@4.1.3 (via @google-cloud/*)

Reproduction

  1. Create a TanStack Start app with @google-cloud/storage or @google-cloud/monitoring dependency (these pull in duplexify → end-of-stream)
  2. Use nitro@3.0.1-alpha.2 with nitro/vite plugin as recommended by the hosting guide
  3. Build and run: bun run .output/server/index.mjs

Now, this was actually working fine before this alpha.2, and it seemed fine until it just started crashing, seemingly out of nowhere after a few runs of some workflows in my app.

Describe the bug

After upgrading to nitro@3.0.1-alpha.2, server builds crash at runtime with:

TypeError: undefined is not an object (evaluating 'commonjsGlobal.Bare')
at requireEndOfStream (/app/.output/server/_libs/end-of-stream.mjs:11:13)
at requireDuplexify (/app/.output/server/_libs/duplexify.mjs:11:32)

Additional context

The end-of-stream@1.4.5 package has Bare runtime detection:
var qnt = global.Bare ? queueMicrotask : process.nextTick.bind(process);

Logs

TypeError: undefined is not an object (evaluating 'commonjsGlobal.Bare')
        at requireEndOfStream (/app/.output/server/_libs/end-of-stream.mjs:11:13)
        at requireDuplexify (/app/.output/server/_libs/duplexify.mjs:11:32)

  11 |   var qnt = commonjsGlobal.Bare ? queueMicrotask : process.nextTick.bind(process);

  error: undefined is not an object (evaluating 'commonjsGlobal.Bare')

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