pinojs / pinojs/thread-stream

Import Errors Hidden by `real-require` Retry

Open
#156 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
261
Forks
31
Avg merge
2d 9h
Merged PRs (30d)
4

Description

In the start function, the error.code === undefined condition in the path which leads to real-require can hide errors which are useful to throw. We had an issue in the file which was imported which resulted in a ReferenceError being thrown. This error has no code value, and therefore the start function tries to require the file. Since the file is a es module, it fails with the ERR_REQUIRE_ESM error. The only way to figure out the real error is to insert a console.log or try to load the module directly.

I am happy to submit a PR. Would one which removes this error.code === undefined condition be accepted? Any suggestions to what kinds of tests should be added?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the start function and inspect the retry path that calls real-require, focusing on the error.code === undefined condition. Add regression coverage showing that an import-time ReferenceError is surfaced instead of being replaced by ERR_REQUIRE_ESM, then run the relevant test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.