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.
I was informed
nodejswould 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
hypotheticalsandactualsif possibleFor example, the documentation alludes to one
hypothetical:From the OS perspective, loading the same
soordll2 or more times would not in-and-of-itself cause a fault. It also appears the Modules loader code creates anodejs-side Module instance for each absolute require('addon.node') path, passing the Module instance to the loadedaddonto 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 ifv8would fault if an attempt was made to create aFunctionTemplatein the sameIsolatefor the same native function, which could occur if anaddon'sInit()function were called more than once;v8could easily return the same template on subsequent calls (similar to how an OS'sdlopenorLoadLibarycall behaves). If theaddondefined 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
actualthat occurs in the real world:--preserve-symlinksdoes preserve symlinks for allrequire()calls, but strangely not that of theentry.jsfile passed onnode's command line. This can create real issues when package managers attempt to run lifecyle events that arenodecommand-lets who'sentry.jsis located in a symlinked folder under somenode_modulesfolder (assuming the command-let itself was configured in package.json to launch with--preserve-symlinks).Providing technical details of all know issues with
--preserve-symlinksis greatly appreciated.