oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.09k stars 2.76k forks source link

TypeError in node_modules is not ignored #5765

Open Kleywalker opened 1 year ago

Kleywalker commented 1 year ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 22.6.0 x86_64 i386

What steps can reproduce the bug?

bun init -y
bun add -d mongodb-memory-server

add file index.test.ts

import { describe, expect, it } from "bun:test";
import { MongoMemoryServer } from "mongodb-memory-server";

describe("Test", () => {
  it("should get uri", async () => {
    const mongoServer = await MongoMemoryServer.create();
    const uri = mongoServer.getUri();
    expect(uri).not.toBeEmpty();
  });
});
bun test

What is the expected behavior?

The test runs without error

What do you see instead?

bun test v1.0.0 (822a00c4)

index.test.ts: Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error: 159 | @param path The Path to Stat 160 | @throws if the error is not "ENOENT" or "EACCES" 161 | / 162 | function statPath(path) { 163 | return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { 164 | return fs_1.promises.stat(path).catch((err) => { ^ TypeError: Invalid path string: can't be empty code: "ERR_INVALID_ARG_TYPE"

  at ./node_modules/mongodb-memory-server-core/lib/util/utils.js:164:15
  at ./node_modules/tslib/tslib.js:169:12
  at new Promise (:1:20)
  at __awaiter (./node_modules/tslib/tslib.js:165:15)
  at statPath (./node_modules/mongodb-memory-server-core/lib/util/utils.js:163:4)
  at ./node_modules/mongodb-memory-server-core/lib/util/utils.js:182:40
  at ./node_modules/tslib/tslib.js:169:12
  at new Promise (:1:20)
  at __awaiter (./node_modules/tslib/tslib.js:165:15)

159 | @param path The Path to Stat 160 | @throws if the error is not "ENOENT" or "EACCES" 161 | / 162 | function statPath(path) { 163 | return (0, tslib_1.__awaiter)(this, void 0, void 0, function () { 164 | return fs_1.promises.stat(path).catch((err) => { ^ TypeError: Invalid path string: can't be empty code: "ERR_INVALID_ARG_TYPE"

  at ./node_modules/mongodb-memory-server-core/lib/util/utils.js:164:15
  at ./node_modules/tslib/tslib.js:169:12
  at new Promise (:1:20)
  at __awaiter (./node_modules/tslib/tslib.js:165:15)
  at statPath (./node_modules/mongodb-memory-server-core/lib/util/utils.js:163:4)
  at ./node_modules/mongodb-memory-server-core/lib/util/utils.js:182:40
  at ./node_modules/tslib/tslib.js:169:12
  at new Promise (:1:20)
  at __awaiter (./node_modules/tslib/tslib.js:165:15)

✗ Test > should get uri [17.72ms]

0 pass 1 fail Ran 1 tests across 1 files. [382.00ms]

Additional information

No response

Kleywalker commented 1 year ago

Works in 1.0.3. Issue can be closed.

DWboutin commented 1 year ago

@Kleywalker thanks a lot, you saved me a lot of time with this issue 💯

JindiHu commented 10 months ago

i'm using bun 1.0.18 the issue still persist tho

1314 |   var ImagePreloader = function () {
1315 |     var proxyImage = function () {
1316 |       var canvas = createTag('canvas');
1317 |       canvas.width = 1;
1318 |       canvas.height = 1;
1319 |       var ctx = canvas.getContext('2d');
                       ^
TypeError: canvas.getContext is not a function. (In 'canvas.getContext("2d")', 'canvas.getContext' is undefined)
      at ./node_modules/lottie-web/build/player/lottie_light.js:1319:17
      at ./node_modules/lottie-web/build/player/lottie_light.js:1322:14
      at ./node_modules/lottie-web/build/player/lottie_light.js:1539:12
      at ./node_modules/lottie-web/build/player/lottie_light.js:2:83
      at ./node_modules/lottie-web/build/player/lottie_light.js:4:102
      at ./node_modules/react-lottie-player/dist/LottiePlayerLight.js:3:14

 0 pass
 1 fail
Ran 1 tests across 1 files. [9.04s]

any idea on how can ignore the TypeError from node_modules?

felipelima-circle commented 7 months ago

It looks like happy-dom still doesn't support the Canvas API. https://github.com/capricorn86/happy-dom/issues/241