@remit/imap-worker 0.0.28 → 0.0.29

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": "@remit/imap-worker",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
package/src/cli.ts CHANGED
@@ -1,4 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ // Plain text on purpose, and the one deliberate exception to the log field
3
+ // contract in deploy/vps/README.md ("Logs"). That contract covers what a
4
+ // container's log driver ships; this file is the `remit-worker` bin, run by hand
5
+ // against a terminal, and is not an entrypoint of any image (see the target list
6
+ // in npm-scripts/docker-bundle.mjs). Do not route it through the logger — usage
7
+ // text and argument errors are for the person who typed the command.
2
8
  import { parseArgs } from "node:util";
3
9
  import { emitEvent } from "./emit.js";
4
10
 
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import cluster from "node:cluster";
3
+ import { randomUUID } from "node:crypto";
3
4
  import {
4
5
  DeleteMessageCommand,
5
6
  ReceiveMessageCommand,
@@ -129,11 +130,16 @@ if (cluster.isPrimary) {
129
130
  isShuttingDown = true;
130
131
  });
131
132
 
132
- // Minimal Lambda Context: `withTelemetry` only reads `functionName`, for the
133
- // line it logs per invocation; the prod handler never touches the rest.
134
- const lambdaContext = {
135
- functionName: `e2e-imap-worker-${queueName}`,
136
- } as Context;
133
+ // Minimal Lambda Context: `withTelemetry` reads `functionName` for the line it
134
+ // logs per invocation and `awsRequestId` for the scope it opens around it, so
135
+ // every line one batch produces shares a `requestId` (deploy/vps/README.md,
136
+ // "Logs"). Minted per batch, like the production poller does — a context built
137
+ // once would put the whole run under one id, which correlates nothing.
138
+ const nextContext = (): Context =>
139
+ ({
140
+ functionName: `e2e-imap-worker-${queueName}`,
141
+ awsRequestId: randomUUID(),
142
+ }) as Context;
137
143
 
138
144
  const pollQueue = async (): Promise<void> => {
139
145
  log.info({ maxMessages }, "Worker started, polling...");
@@ -200,7 +206,7 @@ if (cluster.isPrimary) {
200
206
  })),
201
207
  };
202
208
 
203
- const result = (await activeHandler(event, lambdaContext, () => {})) as
209
+ const result = (await activeHandler(event, nextContext(), () => {})) as
204
210
  | SQSBatchResponse
205
211
  | undefined;
206
212
 
@@ -183,6 +183,7 @@ const syncMailboxesForAccount = async (
183
183
  const mailboxSyncService = new MailboxSyncService(
184
184
  mailboxService,
185
185
  mailboxSpecialUseService,
186
+ log,
186
187
  );
187
188
 
188
189
  const result = await mailboxSyncService