Fix query consistency and refresh dependencies#39
Conversation
|
Owner ping for this maintenance PR: @prajwal-pai77 Requesting review from the manifest-listed owner(s) where GitHub does not already show a pending review request. |
There was a problem hiding this comment.
Code Review
This pull request updates several project dependencies in package.json and package-lock.json, and configures the Couchbase query options to use QueryScanConsistency.RequestPlus in both airline and airport controllers. The review feedback recommends importing and using the official QueryOptions type from the couchbase SDK instead of redefining it locally. Additionally, it highlights the performance implications of using RequestPlus consistency in production environments, suggesting eventual or state-based consistency as more performant alternatives.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| import { makeResponse } from '../shared/makeResponse' | ||
| import { getDatabase } from '../../db/connection' | ||
| import { GetResult, QueryResult } from 'couchbase' | ||
| import { GetResult, QueryResult, QueryScanConsistency } from 'couchbase' |
There was a problem hiding this comment.
Import QueryOptions from the couchbase SDK so that you can use the official SDK type instead of redefining it locally in multiple controller functions.
| import { GetResult, QueryResult, QueryScanConsistency } from 'couchbase' | |
| import { GetResult, QueryResult, QueryScanConsistency, QueryOptions } from 'couchbase' |
| LIMIT: number | ||
| OFFSET: number | ||
| } | ||
| scanConsistency: QueryScanConsistency |
There was a problem hiding this comment.
Instead of defining a custom local QueryOptions type in multiple controller functions (which shadows the official SDK type and duplicates code), you can use the official QueryOptions type imported from the couchbase SDK. This reduces redundancy and improves maintainability.\n\nFor example, you can remove the local type QueryOptions block entirely and declare options as:\ntypescript\nlet options: QueryOptions\n
| ` | ||
| options = { | ||
| parameters: { COUNTRY: country, LIMIT: limit, OFFSET: offset }, | ||
| scanConsistency: QueryScanConsistency.RequestPlus, |
There was a problem hiding this comment.
While using QueryScanConsistency.RequestPlus is highly appropriate for quickstarts and tutorials to ensure newly created documents are immediately visible (Read-Your-Own-Writes consistency), it has significant performance implications in production. RequestPlus forces the query engine to wait for the indexer to catch up with the latest mutations, which can increase query latency and resource utilization under high write loads. For production environments, consider using eventual consistency (QueryScanConsistency.NotBounded) or state-based consistency (such as AtPlus using mutation tokens) to maintain high throughput and low latency.
| import { makeResponse } from '../shared/makeResponse' | ||
| import { getDatabase } from '../../db/connection' | ||
| import { GetResult, QueryResult } from 'couchbase' | ||
| import { GetResult, QueryResult, QueryScanConsistency } from 'couchbase' |
There was a problem hiding this comment.
Import QueryOptions from the couchbase SDK so that you can use the official SDK type instead of redefining it locally in multiple controller functions.
| import { GetResult, QueryResult, QueryScanConsistency } from 'couchbase' | |
| import { GetResult, QueryResult, QueryScanConsistency, QueryOptions } from 'couchbase' |
| LIMIT: number | ||
| OFFSET: number | ||
| } | ||
| scanConsistency: QueryScanConsistency |
There was a problem hiding this comment.
Instead of defining a custom local QueryOptions type in multiple controller functions (which shadows the official SDK type and duplicates code), you can use the official QueryOptions type imported from the couchbase SDK. This reduces redundancy and improves maintainability.\n\nFor example, you can remove the local type QueryOptions block entirely and declare options as:\ntypescript\nlet options: QueryOptions\n
prajwal-pai77
left a comment
There was a problem hiding this comment.
Hi @dex-the-ai
Can you pls check the comment regarding query scan eventual consistency instead of read your own writes consistency?
Summary
express,prettier,ts-jest,yaml) and update the lockfile withnpm audit fixVerification
npm installnpm test(baseline onorigin/main: 3 list/query suites failed before the consistency fix)npm install express@^4.22.2 prettier@^3.8.4 ts-jest@^29.4.11 yaml@^2.9.0npm audit fixnpm testnpm startcurl http://127.0.0.1:3100/api/v1/airport/list --get --data-urlencode country="United States" --data limit=2 --data offset=0curl http://127.0.0.1:3100/api/v1/airport/direct-connections --get --data airport=SFO --data limit=2 --data offset=0curl http://127.0.0.1:3100/api/v1/airline/to-airport --get --data airport=SFO --data limit=2 --data offset=0Evidence
npm testpasses after the fix: 16 suites / 16 tests.travel-samplebucket, including airport listing, direct-connections lookup, airline-to-airport lookup, and the Swagger UI.tutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/screenshots/swagger-ui.pngtutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/walkthrough-swagger.webmtutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/verification.mdtutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/walkthrough-http.txttutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/npm-test-post-audit-fix.logWalkthrough excerpt
Notes
tutorial-maintenance/tutorials.jsonstill says this repo's GitHub Actions runtime is Node 20.x, but the repo itself already declares Node 24 in CI/docs/runtime files.npm auditstill reports 19 moderate dev-only findings in the Jest/Istanbul stack;npm audit fix --forcewants a breakingts-jestchange, so that larger toolchain move was deferred from this sweep.Media evidence
Notes
tutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/screenshots/swagger-ui.pngWalkthrough Swagger
Notes
tutorial-maintenance/runs/couchbase-examples__typescript-quickstart/2026-06-16T1848PDT/walkthrough-swagger.webm