From 9385ce7adfad685c5766b91e0903bccc85c67e7a Mon Sep 17 00:00:00 2001 From: Sahil Purav Date: Tue, 27 Dec 2022 00:47:21 +0530 Subject: [PATCH] fix(js): in new map(key, value), key cannot be an array as it is returning undefined. issue#14017 There was a breaking change done on @nrwl/js package through https://github.com/nrwl/nx/pull/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 --- packages/js/src/executors/node/node.impl.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/js/src/executors/node/node.impl.ts b/packages/js/src/executors/node/node.impl.ts index a192aabb12912..692bf3d51aa94 100644 --- a/packages/js/src/executors/node/node.impl.ts +++ b/packages/js/src/executors/node/node.impl.ts @@ -15,7 +15,7 @@ import { InspectType, NodeExecutorOptions } from './schema'; const hasher = new HashingImpl(); const processMap = new Map(); -const hashedMap = new Map(); +const hashedMap = new Map(); export interface ExecutorEvent { outfile: string; @@ -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( @@ -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;