Skip to content

Commit

Permalink
fix(pacmak): invokeBinScript fails when using symlinked cache
Browse files Browse the repository at this point in the history
This was previously attempted to fix in #4324
While the above fix resolves issues with dependencies, it causes failures when the binary is shelling out to other node processes. This is due to the intrusive and indiscriminate overloading of NODE_OPTIONS, which will forcibly apply to any child processes as well. While in theory adding the symlink flags should not be an issue, this seems to trigger a bug in node: nodejs/node#41000

tl;dr this all sucks very much and we are now just disabling the runtime cache for binaries.
  • Loading branch information
mrgrain committed Jan 3, 2024
1 parent 456f417 commit f16e89d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 69 deletions.
3 changes: 2 additions & 1 deletion gh-pages/content/overview/runtime-architecture.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Runtime Architecture

## Generated Libraries

When using `jsii-pacmak` to generate libraries in different programming
Expand Down Expand Up @@ -149,7 +150,7 @@ The initialization workflow can be described as:
the child's `STDERR` stream, and forwards the decoded data to it's host
process' `STDERR` and `STDOUT` as needed.
4. The *runtime client library* automatically loads the **Javascript** modules
bundled within the *generated bindings* (and their depedencies, bundled in
bundled within the *generated bindings* (and their dependencies, bundled in
other *generated bindings*) into the `node` process when needed.
5. Calls into the *Generated bindings* are encoded into JSON requests and sent
to the child `node` process, which will execute the corresponding
Expand Down
5 changes: 0 additions & 5 deletions packages/@jsii/kernel/src/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1372,11 +1372,6 @@ export class Kernel {
// Make sure the current NODE_OPTIONS are honored if we shell out to node
const nodeOptions = [...process.execArgv];

// When we are using the symlinked version of the cache, we need to preserve both symlink settings for binaries
if (nodeOptions.includes('--preserve-symlinks')) {
nodeOptions.push('--preserve-symlinks-main');
}

return {
command: path.join(packageDir, scriptPath),
args: req.args ?? [],
Expand Down
5 changes: 5 additions & 0 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,11 @@ class PythonModule implements PythonType {
code.line();
code.line('import jsii');
code.line('import sys');
code.line('import os');
code.line();
code.openBlock('if "JSII_RUNTIME_PACKAGE_CACHE" in os.environ');
code.line('os.environ["JSII_RUNTIME_PACKAGE_CACHE"] = "disabled"');
code.closeBlock();
code.line();
emitList(
code,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f16e89d

Please sign in to comment.