Skip to content

RFI: What are the know issues with --preserve-symlinks #9673

@ghost

Description

I was informed nodejs would ideally prefer symlinks are always preserved, but there are known edge cases that prevent defaulting node to this behavior.

I'm requesting someone knowledgeable of the issues enumerate them, ideally separating them into hypotheticals and actuals if possible

For example, the documentation alludes to one hypothetical:

Note, however, that using --preserve-symlinks can have other side effects. Specifically, symbolically linked native modules can fail to load if those are linked from more than one location in the dependency tree (Node.js would see those as two separate modules and would attempt to load the module multiple times, causing an exception to be thrown).

From the OS perspective, loading the same so or dll 2 or more times would not in-and-of-itself cause a fault. It also appears the Modules loader code creates a node js-side Module instance for each absolute require('addon.node') path, passing the Module instance to the loaded addon to initialize. This also would not necessarily cause a fault, as the library is creating and attaching state to the particular Module instance. It's not clear in any docs if v8 would fault if an attempt was made to create a FunctionTemplate in the same Isolate for the same native function, which could occur if an addon's Init() function were called more than once; v8 could easily return the same template on subsequent calls (similar to how an OS's dlopen or LoadLibary call behaves). If the addon defined static state that was in fact state meant to be specific to a Module instance, that could create odd behavior between Module instances, and potentially fault, but has anyone actually experienced any of this, or what the docs alluded to, in the real world?

This is an actual that occurs in the real world:

--preserve-symlinks does preserve symlinks for all require() calls, but strangely not that of the entry.js file passed on node's command line. This can create real issues when package managers attempt to run lifecyle events that are node command-lets who's entry.js is located in a symlinked folder under some node_modules folder (assuming the command-let itself was configured in package.json to launch with --preserve-symlinks).

Providing technical details of all know issues with --preserve-symlinks is greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    moduleIssues and PRs related to the module subsystem.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions