{"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/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/cursor/find_cursor.ts#L469-L498","documentation":"Thrown as MongoTailableCursorError by FindCursor.skip() when findOptions.tailable is true. Tailable cursors start from the current end of a capped collection and stream new inserts; skip is meaningless for that model and the server does not support it on tailable cursors, so the driver rejects it client-side.","triggerScenarios":"coll.find({}, { tailable: true }).skip(5) or coll.find({}, { tailable: true, awaitData: true }).skip(N).","commonSituations":"Reusing a find-options preset with skip on a tailable query; attempting pagination semantics on a tailing cursor.","solutions":["Remove .skip() on tailable cursors","If you need to start from a specific point, filter on a timestamp/_id in the query rather than skip","Use a non-tailable query on the capped collection if you need skip"],"exampleFix":"// before\ncoll.find({}, { tailable: true }).skip(10);\n// after\ncoll.find({ ts: { $gt: lastSeenTs } }, { tailable: true, awaitData: true });","handlingStrategy":"validation","validationCode":"function skipSafe(cursor, n) {\n  if (cursor.findOptions?.tailable) {\n    throw new Error('cannot skip on a tailable cursor; filter by timestamp/_id instead');\n  }\n  return cursor.skip(n);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never call .skip() on tailable cursors","Resume tailing via a filter on a timestamp/_id rather than skip","Use a non-tailable query when you need skip semantics"],"tags":["find","tailable","skip","capped-collection"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}