question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NODE_DEBUG is undefined in bundled env that doesn't support node shimming (eg. Vite)

See original GitHub issue
System:
    OS: macOS 11.2.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 2.00 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
Binaries:
    Node: 14.15.5 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 6.14.11 - /usr/local/bin/npm
Browsers:
    Brave Browser: 89.1.22.67
    Chrome: 89.0.4389.90
    Edge: 89.0.774.57
    Firefox: 86.0
    Safari: 14.0.3
Packages:
    typescript: 4.2.3
    @azure/event-hubs: 5.4.0

Describe the bug The NODE_DEBUG global is undefined when using a bundler such as Vite which doesn’t support node shimming. A repo with a reproduction of the error is available here.

This issue was originally raised in the Vite repository but I have been advised that the issue is related to how @azure/event-hubs is bundled. See the original issue here.

To Reproduce Steps to reproduce the behavior:

  1. Clone the above repo
  2. Run yarn install
  3. Run yarn start
  4. Open the browser console and note the error.

Expected behavior There should be no error.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
chradekcommented, Mar 26, 2021

@andrewcourtice It looks like our dependency rhea requires some shims to work in the browser, so we’ll need to push updates to that before we can fully resolve the issue you’re seeing.

That said, I was able to come up with a workaround for your sample by creating a shims file and importing it in your index.ts.

Here’s what it looks like: npm install --save buffer process src/shims.ts

import * as process from "process";
import { Buffer } from "buffer";
Object.assign(self, {
  process,
  global: self,
  Buffer,
});

src/index.ts

import "./shims";

// rest of code follows

Is this workaround something you’d be able to use until we can update our dependencies/verify we’re not relying on shims in our clients?

0reactions
ramya-rao-acommented, Jun 7, 2021

It looks like our dependency rhea requires some shims to work in the browser, so we’ll need to push updates to that before we can fully resolve the issue you’re seeing.

@chradek Can we log an issue for rhea regarding this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Vite
Vite cannot handle and does not support code that only runs on non-strict mode (sloppy mode). This is because Vite uses ESM and...
Read more >
Why do some variables show up as "undefined" when using ...
@Bergi node starts in the same directory as the selected file. The index.js and .env are in the same directory, so they should...
Read more >
Shimming - webpack
This means writing isolated modules that are well contained and do not rely on hidden dependencies (e.g. globals). Please use these features only...
Read more >
API - esbuild
Supported by: Build ... By default esbuild will not bundle the input files. ... For example, a package may contain code that only...
Read more >
Dependency resolution - Parcel
When building for a node environment, builtin modules are excluded from the bundle, otherwise a shim is included. See the Node docs for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found