@mcinteerj/openclaw-gmail 1.2.7 → 1.2.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/channel.ts +15 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcinteerj/openclaw-gmail",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Gmail channel plugin for OpenClaw - uses gog CLI for secure Gmail access",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/src/channel.ts CHANGED
@@ -335,31 +335,31 @@ export const gmailPlugin: ChannelPlugin<ResolvedGmailAccount> = {
335
335
 
336
336
  ctx.setStatus({ accountId: ctx.accountId, running: true, connected: true });
337
337
 
338
- // Create abort signal for stopping the monitor
339
- const abortController = new AbortController();
338
+ // The channel manager treats startAccount's promise resolving as the channel
339
+ // "exiting", which triggers auto-restart. We must keep this promise pending
340
+ // until the channel manager signals stop via ctx.abortSignal.
341
+ const signal = ctx.abortSignal;
340
342
 
341
- // Start the Gmail polling monitor
342
- monitorGmail({
343
+ // Start the Gmail polling monitor (awaits until signal is aborted)
344
+ await monitorGmail({
343
345
  account: ctx.account,
344
346
  onMessage: async (msg) => {
345
347
  await dispatchGmailMessage(ctx, msg);
346
348
  },
347
- signal: abortController.signal,
349
+ signal,
348
350
  log: ctx.log,
349
351
  setStatus: ctx.setStatus,
350
352
  }).catch((err) => {
351
- ctx.log?.error(`[gmail] Monitor error: ${String(err)}`);
353
+ if (!signal.aborted) {
354
+ ctx.log?.error(`[gmail] Monitor error: ${String(err)}`);
355
+ }
352
356
  });
353
357
 
354
- return {
355
- stop: async () => {
356
- abortController.abort();
357
- if (ctx.account.email) {
358
- activeAccounts.delete(ctx.account.email.toLowerCase());
359
- }
360
- ctx.setStatus({ accountId: ctx.accountId, running: false, connected: false });
361
- },
362
- };
358
+ // Cleanup after monitor exits
359
+ if (ctx.account.email) {
360
+ activeAccounts.delete(ctx.account.email.toLowerCase());
361
+ }
362
+ ctx.setStatus({ accountId: ctx.accountId, running: false, connected: false });
363
363
  },
364
364
  },
365
365
  };