Skip to content

Commit

Permalink
fix(js): in new map(key, value), key cannot be an array as it is retu…
Browse files Browse the repository at this point in the history
…rning undefined. issue#14017

There was a breaking change done on @nrwl/js package through #13813
PR, this has caused an issue#14017 on the frameworks like express, nest.js and wherever
@nrwl/js:node is used as executor.
Once the fresh installation of express or nest.js is done
through nx, after every file changes, it gives EADDRINUSE error.
The issue is caused by using
\"array\" as key in \"new Map(key, value)\" function. I corrected it by using JSON.stringify function.

BREAKING CHANGE:
NA

ISSUES CLOSED: #14017
  • Loading branch information
Sahil Purav committed Dec 26, 2022
1 parent d3ef0ea commit 9385ce7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/js/src/executors/node/node.impl.ts
Expand Up @@ -15,7 +15,7 @@ import { InspectType, NodeExecutorOptions } from './schema';

const hasher = new HashingImpl();
const processMap = new Map<string, ChildProcess>();
const hashedMap = new Map<string[], string>();
const hashedMap = new Map<string, string>();

export interface ExecutorEvent {
outfile: string;
Expand Down Expand Up @@ -92,7 +92,7 @@ async function runProcess(

const hashed = hasher.hashArray(execArgv.concat(options.args));

const hashedKey = [uniqueKey, ...options.args];
const hashedKey = JSON.stringify([uniqueKey, ...options.args]);
hashedMap.set(hashedKey, hashed);

const subProcess = fork(
Expand Down Expand Up @@ -166,7 +166,7 @@ async function killCurrentProcess(
options: NodeExecutorOptions,
signal: string = 'SIGTERM'
) {
const hashedKey = [uniqueKey, ...options.args];
const hashedKey = JSON.stringify([uniqueKey, ...options.args]);
const currentProcessKey = hashedMap.get(hashedKey);
if (!currentProcessKey) return;

Expand Down

0 comments on commit 9385ce7

Please sign in to comment.