Fix setTimeout async anti-pattern in calendar-year component #128

Merged
admin-backup merged 2 commits from copilot/sub-pr-49 into THoguet/issue16 2025-11-18 00:26:19 +01:00
admin-backup commented 2025-11-18 00:17:39 +01:00 (Migrated from 172.24.0.1:8928)

Addresses feedback on wrapping an async function in setTimeout, which doesn't handle the returned Promise and silently swallows errors.

Changes:

  • Replaced setTimeout(async () => {...}, 1) with queueMicrotask(() => { void (async () => {...})(); })
  • Uses queueMicrotask for proper async deferral in the event loop
  • Explicit void operator indicates intentionally unhandled Promise

Before:

setTimeout(async () => {
  const remainingDays = await this.selectedDates.optimizeVacations(...);
  this.userInput.remainingVacationDaysSignal.set(remainingDays);
  this.isLoading.set(false);
}, 1);

After:

queueMicrotask(() => {
  void (async () => {
    const remainingDays = await this.selectedDates.optimizeVacations(...);
    this.userInput.remainingVacationDaysSignal.set(remainingDays);
    this.isLoading.set(false);
  })();
});

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Addresses feedback on wrapping an async function in `setTimeout`, which doesn't handle the returned Promise and silently swallows errors. **Changes:** - Replaced `setTimeout(async () => {...}, 1)` with `queueMicrotask(() => { void (async () => {...})(); })` - Uses `queueMicrotask` for proper async deferral in the event loop - Explicit `void` operator indicates intentionally unhandled Promise **Before:** ```typescript setTimeout(async () => { const remainingDays = await this.selectedDates.optimizeVacations(...); this.userInput.remainingVacationDaysSignal.set(remainingDays); this.isLoading.set(false); }, 1); ``` **After:** ```typescript queueMicrotask(() => { void (async () => { const remainingDays = await this.selectedDates.optimizeVacations(...); this.userInput.remainingVacationDaysSignal.set(remainingDays); this.isLoading.set(false); })(); }); ``` <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
admin-backup commented 2025-11-18 00:17:40 +01:00 (Migrated from 172.24.0.1:8928)

assigned to @Copilot

assigned to `@Copilot`
admin-backup commented 2025-11-18 00:17:40 +01:00 (Migrated from 172.24.0.1:8928)

assigned to @THoguet

assigned to `@THoguet`
admin-backup commented 2025-11-18 00:17:42 +01:00 (Migrated from 172.24.0.1:8928)

mentioned in merge request !49

mentioned in merge request [!49](https://gitea.nessar.fr/nessar/vac-optimizer/pulls/127)
admin-backup commented 2025-11-18 00:23:49 +01:00 (Migrated from 172.24.0.1:8928)

changed title from {-[WIP] Update loading spinner enhancement and progress indication-} to {+Fix setTimeout async anti-pattern in calendar-year component+}

changed title from **{-[WIP] Update loading spinner enhancement and progress indication-}** to **{+Fix setTimeout async anti-pattern in calendar-year component+}**
admin-backup commented 2025-11-18 00:23:56 +01:00 (Migrated from 172.24.0.1:8928)

requested review from @THoguet

requested review from `@THoguet`
admin-backup commented 2025-11-18 00:26:19 +01:00 (Migrated from 172.24.0.1:8928)

Merged by: THoguet at 2025-11-17 23:26:19 UTC

*Merged by: THoguet at 2025-11-17 23:26:19 UTC*
admin-backup (Migrated from 172.24.0.1:8928) closed this pull request 2025-11-18 00:26:19 +01:00
admin-backup (Migrated from 172.24.0.1:8928) merged commit into THoguet/issue16 2025-11-18 00:26:19 +01:00

Preserved source assignment/reviewer metadata. Historical accounts stay inactive.

Source requested reviewers: admin-backup (GitLab user 3).

The linked history record retains original IDs and source dates. No historical identity was merged into nessar or granted new authentication permissions.

<!-- gitlab-to-gitea-assignment:35:MergeRequest:50 --> Preserved source assignment/reviewer metadata. Historical accounts stay inactive. Source requested reviewers: admin-backup (GitLab user 3). The linked history record retains original IDs and source dates. No historical identity was merged into nessar or granted new authentication permissions.

Preserved GitLab !50 history: source attribution, exact timestamps, discussion grouping and review positions. Historical diff snapshots: 1; visible source notes: 6.

gitlab-35-mergerequest-50.md (SHA-256 8a9469b89d1ab9597df589841746a8909fae549a59a2fe5633de663791131f1a)

gitlab-35-mergerequest-50.json (SHA-256 833e850622717a64d1cab1102a23cae7e545a5fc3db64fe4465d6dbd4602cb5a)

Old CI job execution and reports are omitted. Original source files and rollback backups remain protected.

<!-- gitlab-to-gitea-history:35:MergeRequest:50 --> Preserved GitLab !50 history: source attribution, exact timestamps, discussion grouping and review positions. Historical diff snapshots: 1; visible source notes: 6. [gitlab-35-mergerequest-50.md](https://gitea.nessar.fr/attachments/a140499f-686e-4ed2-8a19-00b9e9f3718a) (SHA-256 `8a9469b89d1ab9597df589841746a8909fae549a59a2fe5633de663791131f1a`) [gitlab-35-mergerequest-50.json](https://gitea.nessar.fr/attachments/43627173-fa4c-4288-988c-cc8a894f391b) (SHA-256 `833e850622717a64d1cab1102a23cae7e545a5fc3db64fe4465d6dbd4602cb5a`) Old CI job execution and reports are omitted. Original source files and rollback backups remain protected.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nessar/vac-optimizer#128