Skip to content

[Bug?]: Yarns patching of the fs module subtly breaks in node >20.5.1 #5951

Description

@danieltroger

Self-service

  • I'd be willing to implement a fix

Describe the bug

On node versions above 20.5.1, swc-node stops working with the following cryptic error:

node:internal/process/esm_loader:40
      internalBinding('errors').triggerUncaughtException(
                                ^
TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected array buffer, or typed array to be returned for the "source" from the "transformSource" function but got undefined.
    at new NodeError (node:internal/errors:406:5)
    at assertBufferSource (node:internal/modules/esm/translators:84:9)
    at stringify (node:internal/modules/esm/translators:94:3)
    at createCJSModuleWrap (node:internal/modules/esm/translators:219:12)
    at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:297:10) {
  code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}

Node.js v20.9.0

This is due to the node js worker which deals with something related to custom esm modules has a reference to the unpatched readFileSync function from the fs module, see swc-project/swc-node#736 (comment)

To reproduce

Follow the steps outlined in this issue report: swc-project/swc-node#736 (comment)

Environment

System:
  OS: macOS 14.0 (23A344)
  CPU: Apple M1 Max
Binaries:
  Node: v20.9.0
  Yarn: 4.0.1-git.20231104.hash-afacd23

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo