@vercube/serverless 1.2.1 → 1.2.2

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.
@@ -1,3 +1,4 @@
1
+ import { t as flushTelemetry } from "../../flush-C1KYXrh_.mjs";
1
2
  import { toLambdaHandler } from "srvx/aws-lambda";
2
3
  //#region src/Adapters/aws-lambda/index.ts
3
4
  /**
@@ -27,7 +28,9 @@ import { toLambdaHandler } from "srvx/aws-lambda";
27
28
  */
28
29
  function toServerlessHandler(app) {
29
30
  return toLambdaHandler({ fetch: async (request) => {
30
- return await app.fetch(request);
31
+ const response = await app.fetch(request);
32
+ await flushTelemetry(app);
33
+ return response;
31
34
  } });
32
35
  }
33
36
  //#endregion
@@ -3,7 +3,7 @@ import { App } from "@vercube/core";
3
3
  import { Blob } from "buffer";
4
4
  import { ReadableStream } from "stream/web";
5
5
  import { URLSearchParams } from "url";
6
- //#region ../../node_modules/.pnpm/@azure+functions@4.16.2/node_modules/@azure/functions/types/http.d.ts
6
+ //#region ../../node_modules/.pnpm/@azure+functions@4.16.5/node_modules/@azure/functions/types/http.d.ts
7
7
  /**
8
8
  * HTTP request object. Provided to your function when using HTTP Bindings.
9
9
  */
@@ -156,6 +156,5 @@ interface HttpRequestBodyInit {
156
156
  * @see {@link convertEventToRequest} For details on HttpRequest to Request conversion
157
157
  * @see {@link convertResponseToAzureFunctionsResponse} For details on Response to HttpResponseInit conversion
158
158
  */
159
- declare function toServerlessHandler(app: App): ServerlessHandler<HttpRequest, any>;
160
- //#endregion
161
- export { toServerlessHandler };
159
+ export declare function toServerlessHandler(app: App): ServerlessHandler<HttpRequest, any>;
160
+ //#endregion
@@ -1,3 +1,4 @@
1
+ import { t as flushTelemetry } from "../../flush-C1KYXrh_.mjs";
1
2
  //#region src/Utils/headers.ts
2
3
  /**
3
4
  * Converts a loopable header object to a plain JavaScript object.
@@ -197,7 +198,9 @@ function convertResponseToAzureFunctionsResponse(response) {
197
198
  function toServerlessHandler(app) {
198
199
  return async (event) => {
199
200
  const request = convertEventToRequest(event);
200
- return convertResponseToAzureFunctionsResponse(await app.fetch(request));
201
+ const response = await app.fetch(request);
202
+ await flushTelemetry(app);
203
+ return convertResponseToAzureFunctionsResponse(response);
201
204
  };
202
205
  }
203
206
  //#endregion
@@ -0,0 +1,23 @@
1
+ import { TelemetryRegistry } from "@vercube/core";
2
+ //#region src/Utils/flush.ts
3
+ /**
4
+ * Pushes out buffered telemetry before an invocation returns.
5
+ *
6
+ * A serverless platform is free to freeze the process the instant a response is
7
+ * handed back, which is exactly when a batching span exporter still has the
8
+ * request's spans in memory. Flushing here is the difference between a traced
9
+ * function and one that only reports the invocations that happened to be
10
+ * followed by another.
11
+ *
12
+ * Costs nothing when no telemetry is installed.
13
+ *
14
+ * @param app - The running application
15
+ * @returns Resolves once the buffers are empty
16
+ */
17
+ async function flushTelemetry(app) {
18
+ const hooks = app.container.getOptional(TelemetryRegistry)?.hooks;
19
+ if (!hooks) return;
20
+ await hooks.flush().catch(() => {});
21
+ }
22
+ //#endregion
23
+ export { flushTelemetry as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercube/serverless",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Serverless module for Vercube framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,21 +36,21 @@
36
36
  "azure-function-http"
37
37
  ],
38
38
  "dependencies": {
39
- "srvx": "0.12.5",
40
- "ufo": "1.6.4",
41
- "@vercube/core": "1.2.1",
42
- "@vercube/di": "1.2.1"
39
+ "@vercube/core": "1.2.2",
40
+ "@vercube/di": "1.2.2",
41
+ "srvx": "1.0.5",
42
+ "ufo": "1.6.4"
43
43
  },
44
44
  "devDependencies": {
45
- "@azure/functions": "4.16.2",
46
- "@types/aws-lambda": "8.10.162"
45
+ "@azure/functions": "4.16.5",
46
+ "@types/aws-lambda": "8.10.163"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
51
  "inlinedDependencies": {
52
- "@azure/functions": "4.16.2",
53
- "@types/aws-lambda": "8.10.162"
52
+ "@azure/functions": "4.16.5",
53
+ "@types/aws-lambda": "8.10.163"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "tsdown --config tsdown.config.ts --config-loader=unrun"