Skip to content

Commit b1ffeee

Browse files
bewestCopilot
andcommitted
fix: use ctx.store.db for entry count check
The ctx.entries module isn't always available depending on boot context. Access the entries collection directly via ctx.store.db.collection(). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6a68150 commit b1ffeee

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/lib/production-safety.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ async function checkProductionSafety(ctx, env) {
8888
// Check 2: Entry count threshold
8989
const maxEntries = parseInt(process.env.TEST_SAFETY_MAX_ENTRIES || String(DEFAULT_MAX_ENTRIES), 10);
9090

91-
if (maxEntries > 0 && ctx.entries && ctx.entries.collection) {
91+
if (maxEntries > 0 && ctx.store && ctx.store.db) {
9292
try {
93+
// Access entries collection directly via store
94+
const entriesCol = ctx.store.db.collection('entries');
9395
// Use limit+1 pattern for efficiency - we only need to know if it exceeds threshold
94-
const count = await ctx.entries.collection.countDocuments({}, {
96+
const count = await entriesCol.countDocuments({}, {
9597
limit: maxEntries + 1,
9698
maxTimeMS: 5000 // Don't hang on slow connections
9799
});

0 commit comments

Comments
 (0)