fix(api): disable mongoose autoIndex in check-alerts worker - #2887
fix(api): disable mongoose autoIndex in check-alerts worker#2887Vansh98789 wants to merge 5 commits into
Conversation
The worker only reads from MongoDB, so background createIndexes calls raced the short-lived connection close (endSessions) and failed with MongoExpiredSessionError on mongodb.createIndexes spans. Closes hyperdxio#2734
🦋 Changeset detectedLatest commit: 339430a The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Vansh98789 is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThe PR disables Mongoose automatic index creation for the short-lived check-alerts worker while preserving the existing defaults for other database consumers.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| packages/api/src/models/index.ts | Adds an optional, caller-controlled Mongoose options override while retaining the shared connection defaults. |
| packages/api/src/tasks/checkAlerts/providers/default.ts | Disables automatic index creation specifically when the check-alerts provider initializes its MongoDB connection. |
| .changeset/dull-carrots-bow.md | Records the worker connection fix as an API patch release. |
Reviews (5): Last reviewed commit: "chore: add changeset for autoIndex fix" | Re-trigger Greptile
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Hi @pulpdrew |
|
Hi @Vansh98789 Please add a changeset for this PR by running |
|
Hi @karl-power, I've added the changeset as requested. Could you please review it? Thanks! |
Summary
The
check-alertsworker only reads from MongoDB and never needs to ensure indexes exist-the API service owns that responsibility.Previously, Mongoose's
autoIndextriggered backgroundcreateIndexescalls that raced with the worker's short-lived connection closing (which sendsendSessions). This surfaced asMongoExpiredSessionErroronmongodb.createIndexesspans.This PR:
connectDB({ autoIndex: false }).mongoose.set('autoIndex', false)frominit().Files Changed
packages/api/src/models/index.tspackages/api/src/tasks/checkAlerts/providers/default.tsHow to Test on Vercel Preview
N/A - non-UI change.
References
Closes #2734