Kaynağa Gözat

fix(core): Fix error when using non-TCP transport in workerOptions

Fixes #270
Michael Bromley 5 yıl önce
ebeveyn
işleme
b37ea05026
1 değiştirilmiş dosya ile 6 ekleme ve 3 silme
  1. 6 3
      packages/core/src/bootstrap.ts

+ 6 - 3
packages/core/src/bootstrap.ts

@@ -125,9 +125,12 @@ async function bootstrapWorkerInternal(
     // See https://github.com/nestjs/nest/issues/2777
     // TODO: Remove if & when the above issue is resolved.
     await new Promise((resolve, reject) => {
-        (workerApp as any).server.server.on('error', (e: any) => {
-            reject(e);
-        });
+        const tcpServer = (workerApp as any).server.server;
+        if (tcpServer) {
+            tcpServer.on('error', (e: any) => {
+                reject(e);
+            });
+        }
         workerApp.listenAsync().then(resolve);
     });
     workerWelcomeMessage(config);