@moreapp/common-nodejs 0.14.1 → 0.15.1

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.
@@ -35,6 +35,10 @@ class TerminationHandler {
35
35
  logger_1.logger.error("Server threw an unrecoverable error, shutting down", err);
36
36
  this.shutdown();
37
37
  });
38
+ process.on("unhandledRejection", (reason) => {
39
+ logger_1.logger.error("Unhandled rejection, shutting down", { reason });
40
+ this.shutdown();
41
+ });
38
42
  }
39
43
  shutdown() {
40
44
  if (this.isShuttingDown) {
@@ -219,6 +219,30 @@ vitest_1.vi.mock("node:timers", () => ({
219
219
  await new Promise((resolve) => setImmediate(resolve));
220
220
  (0, vitest_1.expect)(exitSpy).toHaveBeenCalledWith(0);
221
221
  });
222
+ (0, vitest_1.test)("shuts down on an unhandled rejection", async () => {
223
+ const server = createFakeServer();
224
+ const hs = {
225
+ setReady: vitest_1.vi.fn(),
226
+ stop: vitest_1.vi.fn(() => Promise.resolve()),
227
+ };
228
+ const requestTracker = { nrOfActiveRequests: vitest_1.vi.fn(() => 0) };
229
+ const exitSpy = vitest_1.vi.spyOn(process, "exit").mockImplementation(() => undefined);
230
+ new TerminationHandler_1.default(server, hs, requestTracker);
231
+ // Call the listener directly; emitting on process would also reach vitest's own handler
232
+ const listener = process.listeners("unhandledRejection").at(-1);
233
+ process.off("unhandledRejection", listener);
234
+ const reason = new Error("boom");
235
+ listener(reason, Promise.resolve());
236
+ (0, vitest_1.expect)(vitest_1.vi.mocked(logger_1.logger.error)).toHaveBeenCalledWith("Unhandled rejection, shutting down", {
237
+ reason,
238
+ });
239
+ (0, vitest_1.expect)(hs.setReady).toHaveBeenCalledWith(false);
240
+ // eslint-disable-next-line @typescript-eslint/unbound-method
241
+ (0, vitest_1.expect)(server.close).toHaveBeenCalled();
242
+ intervalCb?.();
243
+ await new Promise((resolve) => setImmediate(resolve));
244
+ (0, vitest_1.expect)(exitSpy).toHaveBeenCalledWith(0);
245
+ });
222
246
  (0, vitest_1.test)("ignores a second shutdown call", () => {
223
247
  const server = createFakeServer();
224
248
  const hs = {
@@ -1,9 +1,9 @@
1
- import * as types from "@opentelemetry/instrumentation/build/src/types";
1
+ import { Instrumentation } from "@opentelemetry/instrumentation";
2
2
  export declare const start: (serviceName: string, { http, extraInstrumentations, debug, }: {
3
3
  http?: {
4
4
  portsToInstrument: number[];
5
5
  };
6
- extraInstrumentations?: types.Instrumentation[];
6
+ extraInstrumentations?: Instrumentation[];
7
7
  debug?: boolean;
8
8
  }) => void;
9
9
  export declare const shutdown: () => Promise<void>;
@@ -12,7 +12,7 @@ declare const _default: {
12
12
  http?: {
13
13
  portsToInstrument: number[];
14
14
  };
15
- extraInstrumentations?: types.Instrumentation[];
15
+ extraInstrumentations?: Instrumentation[];
16
16
  debug?: boolean;
17
17
  }) => void;
18
18
  shutdown: () => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moreapp/common-nodejs",
3
- "version": "0.14.1",
3
+ "version": "0.15.1",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,22 +29,22 @@
29
29
  "dist/**/*"
30
30
  ],
31
31
  "dependencies": {
32
- "@opentelemetry/api": "1.9.1",
32
+ "@opentelemetry/api": "1.10.0",
33
33
  "@opentelemetry/core": "2.12.0",
34
- "@opentelemetry/exporter-trace-otlp-grpc": "0.223.0",
35
- "@opentelemetry/instrumentation": "0.223.0",
36
- "@opentelemetry/instrumentation-dns": "0.66.0",
37
- "@opentelemetry/instrumentation-express": "0.71.1",
38
- "@opentelemetry/instrumentation-http": "0.223.0",
39
- "@opentelemetry/instrumentation-winston": "0.68.1",
34
+ "@opentelemetry/exporter-trace-otlp-grpc": "0.301.0",
35
+ "@opentelemetry/instrumentation": "0.301.0",
36
+ "@opentelemetry/instrumentation-dns": "0.68.0",
37
+ "@opentelemetry/instrumentation-express": "0.73.0",
38
+ "@opentelemetry/instrumentation-http": "0.301.0",
39
+ "@opentelemetry/instrumentation-winston": "0.70.0",
40
40
  "@opentelemetry/resources": "2.12.0",
41
- "@opentelemetry/sdk-node": "0.223.0",
41
+ "@opentelemetry/sdk-node": "0.301.0",
42
42
  "@opentelemetry/sdk-trace-base": "2.12.0",
43
43
  "@opentelemetry/sdk-trace-node": "2.12.0",
44
- "@opentelemetry/semantic-conventions": "1.43.0",
45
- "axios": "1.20.0",
44
+ "@opentelemetry/semantic-conventions": "1.45.0",
45
+ "axios": "1.21.0",
46
46
  "content-disposition-parser": "1.0.2",
47
- "date-and-time": "4.6.0",
47
+ "date-and-time": "4.7.1",
48
48
  "express": "5.3.0",
49
49
  "lodash": "4.18.1",
50
50
  "prom-client": "15.1.3",
@@ -53,25 +53,25 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/express": "5.0.6",
56
- "@types/lodash": "4.17.26",
57
- "@types/node": "24.19.2",
58
- "@typescript-eslint/eslint-plugin": "8.72.0",
59
- "@typescript-eslint/parser": "8.72.0",
60
- "@vitest/coverage-v8": "5.0.5",
61
- "@vitest/ui": "5.0.5",
56
+ "@types/lodash": "4.17.27",
57
+ "@types/node": "26.6.6",
58
+ "@typescript-eslint/eslint-plugin": "8.72.1",
59
+ "@typescript-eslint/parser": "8.72.1",
60
+ "@vitest/coverage-v8": "5.1.0",
61
+ "@vitest/ui": "5.1.0",
62
62
  "eslint": "9.39.5",
63
63
  "eslint-config-prettier": "10.1.8",
64
64
  "eslint-plugin-prettier": "5.5.7",
65
65
  "husky": "9.1.7",
66
66
  "lint-staged": "17.6.0",
67
- "nock": "15.0.4",
67
+ "nock": "15.0.6",
68
68
  "prettier": "3.9.10",
69
69
  "ts-node": "10.9.2",
70
70
  "typescript": "6.0.3",
71
- "typescript-eslint": "8.72.0",
72
- "vite": "8.3.4",
73
- "vitest": "5.0.5",
74
- "vitest-mock-extended": "5.1.1"
71
+ "typescript-eslint": "8.72.1",
72
+ "vite": "8.3.6",
73
+ "vitest": "5.1.0",
74
+ "vitest-mock-extended": "6.0.0"
75
75
  },
76
76
  "prettier": {
77
77
  "printWidth": 100,