@travetto/compiler 3.4.0-rc.3 → 3.4.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/compiler",
3
- "version": "3.4.0-rc.3",
3
+ "version": "3.4.0-rc.5",
4
4
  "description": "The compiler infrastructure for the Travetto framework",
5
5
  "keywords": [
6
6
  "compiler",
@@ -37,7 +37,7 @@
37
37
  "@types/node": "^20.8.10"
38
38
  },
39
39
  "peerDependencies": {
40
- "@travetto/cli": "^3.4.0-rc.4"
40
+ "@travetto/cli": "^3.4.0-rc.7"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "@travetto/cli": {
@@ -22,7 +22,7 @@ export class CompilerServer {
22
22
  req.on('data', (chunk) => body.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk));
23
23
  req.on('end', () => {
24
24
  try {
25
- res(JSON.parse(Buffer.concat(body).toString('utf8')))
25
+ res(JSON.parse(Buffer.concat(body).toString('utf8')));
26
26
  } catch (err) {
27
27
  rej(err);
28
28
  }
@@ -180,23 +180,27 @@ export class CompilerServer {
180
180
  }
181
181
 
182
182
  // Terminate, after letting all remaining events emit
183
- setImmediate(() => this.close());
183
+ await this.close();
184
184
  }
185
185
 
186
186
  /**
187
187
  * Close server
188
188
  */
189
189
  async close(): Promise<unknown> {
190
+ if (this.signal.aborted) {
191
+ return;
192
+ }
193
+
190
194
  log('info', 'Closing down server');
191
- setTimeout(async () => {
192
- this.#shutdown.abort();
195
+ await new Promise(r => {
196
+ this.#server.close(r);
193
197
  this.#emitEvent({ type: 'state', payload: { state: 'close' } });
194
198
  this.#server.unref();
195
- await new Promise(r => {
196
- this.#server.close(r);
197
- setImmediate(() => this.#server.closeAllConnections());
199
+ setImmediate(() => {
200
+ this.#server.closeAllConnections();
201
+ this.#shutdown.abort();
198
202
  });
199
- }, 10);
203
+ });
200
204
  return { closing: true };
201
205
  }
202
206
 
package/support/types.ts CHANGED
@@ -21,7 +21,7 @@ export type CompilerServerInfo = {
21
21
  serverPid: number;
22
22
  compilerPid: number;
23
23
  state: CompilerStateType;
24
- mode: CompilerMode,
24
+ mode: CompilerMode;
25
25
  iteration: number;
26
26
  url: string;
27
27
  env?: Record<string, string>;