{"record":{"id":"f98fad4846a83ede","repo":"mongodb/node-mongodb-native","slug":"tailable-cursor-does-not-support-skip","errorCode":null,"errorMessage":"Tailable cursor does not support skip","messagePattern":"Tailable cursor does not support skip","errorType":"exception","errorClass":"MongoTailableCursorError","httpStatus":null,"severity":"error","filePath":"src/cursor/find_cursor.ts","lineNumber":487,"sourceCode":"    }\n\n    if (typeof value !== 'number') {\n      throw new MongoInvalidArgumentError('Operation \"limit\" requires an integer');\n    }\n\n    this.findOptions.limit = value;\n    return this;\n  }\n\n  /**\n   * Set the skip for the cursor.\n   *\n   * @param value - The skip for the cursor query.\n   */\n  skip(value: number): this {\n    this.throwIfInitialized();\n    if (this.findOptions.tailable) {\n      throw new MongoTailableCursorError('Tailable cursor does not support skip');\n    }\n\n    if (typeof value !== 'number') {\n      throw new MongoInvalidArgumentError('Operation \"skip\" requires an integer');\n    }\n\n    this.findOptions.skip = value;\n    return this;\n  }\n}\n","sourceCodeStart":469,"sourceCodeEnd":498,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/cursor/find_cursor.ts#L469-L498","documentation":"Thrown by FindCursor.skip when findOptions.tailable is true. Skip on a tailable cursor is meaningless because the cursor follows live inserts in natural order; skipping N documents at cursor open does not correspond to a stable position in the stream. Subclass MongoTailableCursorError.","triggerScenarios":"collection.find({}, { tailable: true }).skip(50); setting tailable via addCursorFlag then calling .skip(); applying pagination defaults to a tailing query.","commonSituations":"A shared query builder that injects skip for pagination on every find; converting a paginated query to tailable without removing skip.","solutions":["Remove .skip() from the tailable cursor; track a resume token / timestamp on the client instead.","Use a non-tailable query if you need offset pagination.","Filter with a query (e.g. { ts: { $gt: lastSeen } }) instead of skipping."],"exampleFix":"// before\ncollection.find({}, { tailable: true }).skip(50);\n\n// after\ncollection.find({ ts: { $gt: lastSeenTs } }, { tailable: true });","handlingStrategy":"validation","validationCode":"function safeSkip(cursor, value, opts) {\n  if (opts?.tailable) throw new Error('Cannot skip on a tailable cursor; filter by resume marker');\n  return cursor.skip(value);\n}","typeGuard":"function isTailableCursor(opts) { return Boolean(opts?.tailable); }","tryCatchPattern":null,"preventionTips":["Use a resume token / timestamp filter instead of skip on tailable cursors.","Do not apply generic pagination defaults to tailable queries."],"tags":["find","tailable","capped-collection","skip"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}