App crash when connecting while a bucket is being created

git clone https://github.com/cbjs-dev/cbjs.git
cd cbjs
nvm install && nvm use
git checkout vitest/keyspace-isolation
pnpm i
pnpm run build
CBPPLOGLEVEL=trace vitest --project=project:keyspace-isolation --run

When you checkout the repo, it will work.
Open the file packages/vitest/src/keyspaceIsolation/KeyspaceIsolationPool.ts and go to line 364.

// This works
this.clusterPromise = sleep(500).then(() =>
  connect(params.connectionString, params.credentials)
);

// This crashes
this.clusterPromise = connect(params.connectionString, params.credentials);

I get this trace :

[2024-04-29 10:42:27.784]    1ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x1f, fextlen=3, keylen=0, extlen=0, datatype=0, status=0, bodylen=41, opaque=8, cas=0}
[2024-04-29 10:42:27.784]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> supported_features=[tcp_nodelay, mutation_seqno, xattr, xerror, select_bucket, snappy, json, duplex, clustermap_change_notification, unordered_execution, tracing, alt_request_support, sync_replication, collections, preserve_ttl, vattr, subdoc_create_as_deleted, subdoc_replica_read, deduplicate_not_my_vbucket_clustermap]
[2024-04-29 10:42:27.784]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x20, fextlen=3, keylen=0, extlen=0, datatype=0, status=0, bodylen=45, opaque=9, cas=0}
[2024-04-29 10:42:27.784]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x21, fextlen=3, keylen=0, extlen=0, datatype=0, status=33, bodylen=183, opaque=10, cas=0}
[2024-04-29 10:42:27.784]    0ms [trac] [61894,1121462] decoding attribute list [r=0x18 0x63 0x1f 0x5a 0xffffff99 0xffffffbb 0xffffffc6 0xffffffba5dcaa6816eb8e3e2,s=q4koz+brR1CfUDLRXShQylNrSRZpMy57yvdRAsCK1ZGyycPBV1572fu2RAXLS0vfXWtzw552z1ARePhjATVw+w==,i=15000]
[2024-04-29 10:42:27.790]    6ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0x22, fextlen=0, keylen=12, extlen=0, datatype=0, vbucket=0, bodylen=191, opaque=11, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x22, fextlen=3, keylen=0, extlen=0, datatype=0, status=0, bodylen=93, opaque=11, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0xfe, fextlen=0, keylen=0, extlen=0, datatype=0, vbucket=0, bodylen=2, opaque=12, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0x89, fextlen=0, keylen=15, extlen=0, datatype=0, vbucket=0, bodylen=15, opaque=13, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0xb5, fextlen=0, keylen=0, extlen=0, datatype=0, vbucket=0, bodylen=0, opaque=14, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0xfe, fextlen=3, keylen=0, extlen=0, datatype=1, status=0, bodylen=9671, opaque=12, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x89, fextlen=3, keylen=0, extlen=0, datatype=0, status=36, bodylen=3, opaque=13, cas=0}
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> unable to select bucket: cbjs_b_638749ac, probably the bucket does not exist
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] all nodes failed to bootstrap, triggering DNS-SRV refresh, ec=bucket_not_found (10), last endpoint="localhost:11210"
[2024-04-29 10:42:27.791]    0ms [warn] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> failed to bootstrap session ec=bucket_not_found (10), bucket="cbjs_b_638749ac"
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> stop MCBP connection, reason=node_not_available
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] Query DNS-SRV: address="localhost", service="_couchbase", nameserver="1.1.1.1:53"
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] Query DNS-SRV (UDP) address="1.1.1.1:53", udp_timeout=250ms, total_timeout=500ms
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> destroy MCBP connection

This could be related to CXXCBC-503 but I had similar issue consistently before ( see packages/vitest/src/ServerTestContext.ts ).

  1. Is the stack trace from this crash the same as the other crash you said was fixed in 4.3.1? Is this issue fixed by 4.3.1?

  2. The reproducer doesn’t find vitest as it is not in the PATH.

 % CBPPLOGLEVEL=trace vitest --project=project:keyspace-isolation --run
zsh: command not found: vitest

I assume that ./node_modules/.bin/vitest is the one that should be executed.

  1. The reproducer doesn’t work for me without first doing “npm run build”
% CBPPLOGLEVEL=trace ./node_modules/.bin/vitest --project=project:keyspace-isolation --run

**RUN** v1.5.2 /Users/michaelreiche/cbj2/cbjs

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ **Unhandled Errors** ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

**Vitest caught 5 unhandled errors during the test run.**

**This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.**

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ **Unhandled Error** ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

**Error**: Failed to load url /Users/michaelreiche/cbj2/cbjs/tests/keyspace-isolation/@cbjsdev/vitest/runner (resolved id: /Users/michaelreiche/cbj2/cbjs/tests/keyspace-isolation/@cbjsdev/vitest/runner). Does the file exist?

❯ loadAndTransform node_modules/.pnpm/vite@5.2.10_@types+node@20.12.7/node_modules/vite/dist/node/chunks/dep-DkOS1hkm.js:53878:21

❯ ViteNodeServer._transformRequest node_modules/.pnpm/vite-node@1.5.2_@types+node@20.12.7/node_modules/vite-node/dist/server.mjs:413:16

❯ ViteNodeServer._fetchModule node_modules/.pnpm/vite-node@1.5.2_@types+node@20.12.7/node_modules/vite-node/dist/server.mjs:379:17

❯ MessagePort.<anonymous> node_modules/.pnpm/vitest@1.5.2_@types+node@20.12.7_@vitest+ui@1.5.2/node_modules/vitest/dist/vendor/index.8bPxjt7g.js:65:20

npm build …

% npm run build

> @cbjsdev/monorepo@1.0.0 build

> lerna run --stream build --scope @cbjsdev/*

(node:62084) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

(Use `node --trace-deprecation ...` to show where the warning was created)

lerna notice cli v8.1.2

lerna notice filter including "@cbjsdev/*"

lerna info filter [ '@cbjsdev/*' ]

**Lerna (powered by Nx)** Running target **build** for 5 projects:

- @cbjsdev/cbjs

- @cbjsdev/http-client

- @cbjsdev/n1ql-parser

- @cbjsdev/shared

- @cbjsdev/vitest

————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

> @cbjsdev/shared:build

**@cbjsdev/shared:** > @cbjsdev/shared@1.6.1 build /Users/michaelreiche/cbj2/cbjs/packages/shared

**@cbjsdev/shared:** > tsc -p tsconfig.build.json

> @cbjsdev/http-client:build

> @cbjsdev/n1ql-parser:build

**@cbjsdev/http-client:** > @cbjsdev/http-client@1.6.1 build /Users/michaelreiche/cbj2/cbjs/packages/http-client

**@cbjsdev/http-client:** > tsc -p tsconfig.build.json

**@cbjsdev/n1ql-parser:** > @cbjsdev/n1ql-parser@1.1.3 build /Users/michaelreiche/cbj2/cbjs/packages/n1ql-parser

**@cbjsdev/n1ql-parser:** > tsc -p tsconfig.build.json

> @cbjsdev/cbjs:build

**@cbjsdev/cbjs:** > @cbjsdev/cbjs@1.6.1 build /Users/michaelreiche/cbj2/cbjs/packages/cbjs

**@cbjsdev/cbjs:** > tsc -p tsconfig.build.json

> @cbjsdev/vitest:build

**@cbjsdev/vitest:** > @cbjsdev/vitest@1.6.1 build /Users/michaelreiche/cbj2/cbjs/packages/vitest

**@cbjsdev/vitest:** > tsc -p tsconfig.build.json

————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

**Lerna (powered by Nx)** Successfully ran target **build** for 5 projects

npm notice

npm notice New minor version of npm available! 10.5.0 -> 10.6.0

npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.6.0

npm notice Run npm install -g npm@10.6.0 to update!

npm notice
  1. The reproducer doesn’t reproduce…
 % CBPPLOGLEVEL=trace ./node_modules/.bin/vitest  --project=project:keyspace-isolation --run

 RUN  v1.5.2 /Users/michaelreiche/cbj2/cbjs

(node:62352) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
   ❯ keyspace isolation scope (10)
     ❯ per-test (2)
       ⠋ test a should create its own isolation
       · test b should create its own isolation
     · per-suite (4)
     · local (4)
[2024-04-29 09:43:29.705] 2003ms [debu] [62352,11150769] Selected nameserver: "10.100.189.12" from "/etc/resolv.conf"
[2024-04-29 09:43:29.707]    1ms [debu] [62352,11150769] open cluster, id: "613ad4-8339-184a-f87c-d88450c3dad9e4", core version: "1.0.0+", {"bootstrap_nodes":[{"hostname":"localhost","port":"11210"}],"options":{"analytics_timeout":"75000ms","bootstrap_timeout":"10000ms","config_idle_redial_timeout":"300000ms","config_poll_floor":"50ms","config_poll_interval":"2500ms","connect_timeout":"2000ms","disable_mozilla_ca_certificates":false,"dns_config":{"nameserver":"10.100.189.12","port":53,"timeout":"500ms"},"dump_configuration":false,"enable_clustermap_notification":true,"enable_compression":true,"enable_dns_srv":true,"enable_metrics":true,"enable_mutation_tokens":true,"enable_tcp_keep_alive":true,"enable_tls":false,"enable_tracing":true,"enable_unordered_execution":true,"idle_http_connection_timeout":"1000ms","key_value_durable ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
   ❯ keyspace isolation scope (10)
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
   ❯ keyspace isolation scope (10)
     ❯ per-test (2)
       ⠹ test a should create its own isolation
       · test b should create its own isolation
     · per-suite (4)
     · local (4)
[2024-04-29 09:43:29.729]    1ms [trac] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> resolved "localhost:11210" to 2 endpoint(s)
[2024-04-29 09:43:29.729]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to ::1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:29.729]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to ::1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
[2024-04-29 09:43:29.729]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to 127.0.0.1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:29.729]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to 127.0.0.1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
[2024-04-29 09:43:29.729]    0ms [erro] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> no more endpoints left to connect to "localhost:11 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
   ❯ keyspace isolation scope (10)
     ❯ per-test (2)
       ⠹ test a should create its own isolation
       · test b should create its own isolation
     · per-suite (4)
     · local (4)
[2024-04-29 09:43:30.230]  493ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> attempt to establish MCBP connection
[2024-04-29 09:43:30.231]    0ms [trac] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> resolved "localhost:11210" to 2 endpoint(s)
[2024-04-29 09:43:30.231]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to ::1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:30.232]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to ::1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
[2024-04-29 09:43:30.232]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to 127.0.0.1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:30.232]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to 127.0.0.1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
   ❯ keyspace isolation scope (10)
     ❯ per-test (2)
       ⠹ test a should create its own isolation
       · test b should create its own isolation
     · per-suite (4)
     · local (4)
[2024-04-29 09:43:30.733]  484ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> attempt to establish MCBP connection
[2024-04-29 09:43:30.734]    1ms [trac] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> resolved "localhost:11210" to 2 endpoint(s)
[2024-04-29 09:43:30.734]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to ::1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:30.734]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to ::1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
[2024-04-29 09:43:30.734]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to 127.0.0.1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:30.735]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to 127.0.0.1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
   ❯ keyspace isolation scope (10)
     ❯ per-test (2)
       ⠹ test a should create its own isolation
       · test b should create its own isolation
     · per-suite (4)
     · local (4)
[2024-04-29 09:43:31.236]  477ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> attempt to establish MCBP connection
[2024-04-29 09:43:31.236]    0ms [trac] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> resolved "localhost:11210" to 2 endpoint(s)
[2024-04-29 09:43:31.236]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to ::1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:31.237]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to ::1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
[2024-04-29 09:43:31.237]    0ms [debu] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> connecting to 127.0.0.1:11210 ("localhost:11210"), timeout=2000ms
[2024-04-29 09:43:31.237]    0ms [warn] [62352,11150785] [613ad4-8339-184a-f87c-d88450c3dad9e4/e30fda-1790-924c-065a-42ba65293a987c/plain/-] <localhost:11210> unable to connect to 127.0.0.1:11210: 61 (Connection refused), check server ports and cluster encryption setting. is_open=true
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)
 ❯ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10)

@mreiche thank you for your reply. I don’t get notifications, I don’t know why, they are enabled in the settings. EDIT : alright I think I have the settings right this time.

It’s not the same stack trace. The previous stack trace was a segfault log issues by the package ‘segfault-handler’. The current stack trace is issued by the couchbase binaries. The previous issue was fixed by 4.3.1, the current one is not.

I don’t why you don’t have this in your path, it’s probably a system-level thing, during the setup of nvm maybe.

Alright, I added the command to the OP.

Again, huh ?
I’m using MacOS Sonoma 14.4.1 on an Apple Silicon chip, running a single node of CB 7.6.1 EE as a docker container.

So the tests exit properly on your machine, with all tests successful ?

EDIT : from what I can see from the logs, it seems that you have a connection issue

Huh. My ever-present local couchbase server was not running. I’ll try it again.

If you post the information that you already have (the stack trace), it might spare both of us the effort of duplicating the issue.

@mreiche I have shared the trace in the OP but here it is again :

[2024-04-29 10:42:27.784]    1ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x1f, fextlen=3, keylen=0, extlen=0, datatype=0, status=0, bodylen=41, opaque=8, cas=0}
[2024-04-29 10:42:27.784]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> supported_features=[tcp_nodelay, mutation_seqno, xattr, xerror, select_bucket, snappy, json, duplex, clustermap_change_notification, unordered_execution, tracing, alt_request_support, sync_replication, collections, preserve_ttl, vattr, subdoc_create_as_deleted, subdoc_replica_read, deduplicate_not_my_vbucket_clustermap]
[2024-04-29 10:42:27.784]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x20, fextlen=3, keylen=0, extlen=0, datatype=0, status=0, bodylen=45, opaque=9, cas=0}
[2024-04-29 10:42:27.784]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x21, fextlen=3, keylen=0, extlen=0, datatype=0, status=33, bodylen=183, opaque=10, cas=0}
[2024-04-29 10:42:27.784]    0ms [trac] [61894,1121462] decoding attribute list [r=0x18 0x63 0x1f 0x5a 0xffffff99 0xffffffbb 0xffffffc6 0xffffffba5dcaa6816eb8e3e2,s=q4koz+brR1CfUDLRXShQylNrSRZpMy57yvdRAsCK1ZGyycPBV1572fu2RAXLS0vfXWtzw552z1ARePhjATVw+w==,i=15000]
[2024-04-29 10:42:27.790]    6ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0x22, fextlen=0, keylen=12, extlen=0, datatype=0, vbucket=0, bodylen=191, opaque=11, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x22, fextlen=3, keylen=0, extlen=0, datatype=0, status=0, bodylen=93, opaque=11, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0xfe, fextlen=0, keylen=0, extlen=0, datatype=0, vbucket=0, bodylen=2, opaque=12, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0x89, fextlen=0, keylen=15, extlen=0, datatype=0, vbucket=0, bodylen=15, opaque=13, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP send {magic=0x80, opcode=0xb5, fextlen=0, keylen=0, extlen=0, datatype=0, vbucket=0, bodylen=0, opaque=14, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0xfe, fextlen=3, keylen=0, extlen=0, datatype=1, status=0, bodylen=9671, opaque=12, cas=0}
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> MCBP recv {magic=0x18, opcode=0x89, fextlen=3, keylen=0, extlen=0, datatype=0, status=36, bodylen=3, opaque=13, cas=0}
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> unable to select bucket: cbjs_b_638749ac, probably the bucket does not exist
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] all nodes failed to bootstrap, triggering DNS-SRV refresh, ec=bucket_not_found (10), last endpoint="localhost:11210"
[2024-04-29 10:42:27.791]    0ms [warn] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> failed to bootstrap session ec=bucket_not_found (10), bucket="cbjs_b_638749ac"
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> stop MCBP connection, reason=node_not_available
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] Query DNS-SRV: address="localhost", service="_couchbase", nameserver="1.1.1.1:53"
[2024-04-29 10:42:27.791]    0ms [trac] [61894,1121462] Query DNS-SRV (UDP) address="1.1.1.1:53", udp_timeout=250ms, total_timeout=500ms
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> destroy MCBP connection

This? It should be retried. When I run there are 7 of those messages.

[2024-04-29 10:42:27.791]    0ms [warn] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> failed to bootstrap session ec=bucket_not_found (10), bucket="cbjs_b_638749ac"
[2024-04-29 10:42:27.791]    0ms [debu] [61894,1121462] [949814-f7e9-e14c-2b7b-ab21f8f573032e/fe28b9-9a59-3d43-2489-94e174447b56cc/plain/cbjs_b_638749ac] <localhost/::1:11210> stop MCBP connection, reason=node_not_available

When I run it some of the tests fail. And this will fail - because store.library.books does not exist (although I think your example does some gymnastics to instead create and use cbjs_xxxx```
FAIL |project:keyspace-isolation| tests/kv.spec.ts > kv > should isolate an insert
AmbiguousTimeoutError: ambiguous timeout
❯ Module.errorFromCpp …/…/packages/cbjs/src/bindingutilities.ts:762:14
❯ Collection.insert …/…/packages/cbjs/src/collection.ts:1130:19
❯ tests/kv.spec.ts:21:5
19|
20| const collection = cluster.bucket(‘store’).scope(‘library’).collection(‘books’);
21| await collection.insert(‘docKey’, {
| ^
22| title: ‘insert’,
23| });

This is the whole trace and according to it, there is no retry.

Why does it fails if a bucket does not exist ? I’m starting a new connection to the cluster, why a bucket being created is an issue ? Especially since the creation was initiated by another connection.

Why does ithe insert into a collection in a bucket fail when the bucket doesn’t exist? It’s because the bucket doesn’t exist. Even if you are creating the bucket.scope.collection, the default timeout on an insert is 2.5 seconds. So if the bucket is not available in that time, the operation times-out.

The issue I hit in the previous version was that my cluster did not have enough space and the creation of a 256m bucket failed.

I made two types of changes to your project.

  1. reduce the the size of the buckets being created from 256M to 100M.
  2. use a 10 second timeout for kv operations.

It doesn’t “crash”, most of the tests pass.

The test crash during the connection. Not during the insert. It never reaches that point.

If you run only that file, the tests succeed. Try this :

vitest kv.spec.ts --project=project:keyspace-isolation --run

Also, like I mentioned in the OP, adding a sleep before trying to connect solves the issue.

EDIT : all tests should pass when run together, as they all succeed when run file by file.

And as I mentioned, the issue is that the bucket.scope.collection is not created yet.

It runs fine - with the exception of your tests failing. Why are you calling this a “crash”? You try to use a bucket that isn’t there (yet) and it doesn’t work.

% ./node_modules/.bin/vitest --project=project:keyspace-isolation --run

RUN  v1.5.2 /Users/michaelreiche/cbj2/cbjs

(node:41468) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
(node:41468) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1517ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1517ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1517ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 8799ms
 ✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1517ms
 ❯ |project:keyspace-isolation| tests/kv.spec.ts (4) 5702ms
   ❯ kv (4) 5668ms
     ✓ whatev
     ✓ should isolate an insert 3974ms
     × should isolate a get 1107ms
     ✓ should throw the original error 583ms
 ❯ |project:keyspace-isolation| tests/kv-no-isolation.spec.ts (1) 846ms
   ❯ kv-no-isolation (1) 845ms
     × should throw the original error 843ms
 ✓ |project:keyspace-isolation| tests/test-without-suite.spec.ts (1)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  |project:keyspace-isolation| tests/kv-no-isolation.spec.ts > kv-no-isolation > should throw the original error
 FAIL  |project:keyspace-isolation| tests/kv.spec.ts > kv > should isolate a get
CouchbaseError: Unknown Couchbase error: Operation aborted.
 ❯ Module.errorFromCpp ../../packages/cbjs/src/bindingutilities.ts:899:10
 ❯ ../../packages/cbjs/src/cluster.ts:812:23

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { context: undefined }
Caused by: Error: Operation aborted.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 89 }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 Test Files  2 failed | 3 passed (5)
      Tests  2 failed | 15 passed | 1 skipped (18)
   Start at  10:36:47
   Duration  23.64s (transform 1.59s, setup 1.39s, collect 36ms, tests 16.87s, environment 1ms, prepare 2.85s)

 HTML  Report is generated
       You can run npx vite preview --outDir tests-report to see the test results.

You don’t have a crash but I have. It ends with « [xxxx] Abort » (I’m not on my machine right now).

It fails when I try to establish a connection to the cluster. Not when I try to insert something into the collection that does not exist.

EDIT : did you reuse the cloned repo ? If so, please run a git fetch and git checkout origin/vitest/keyspace-isolation

You don’t have a crash but I have. It ends with « [xxxx] Abort

I have shared the trace in the OP but here it is again.

¯\(ツ)

It fails when I try to establish a connection to the cluster.

Maybe you have an issue with the your code that connects to the cluster.
I noticed that the failures I do see, are in tests with the second, third etc. calls to getCluster() . They don’t occur in the first call. And when I comment out the test with the first call, then the test with the (previously) second call works.

import { beforeAll, describe, it } from 'vitest';

import { DocumentExistsError } from '@cbjsdev/cbjs';
import { sleep } from '@cbjsdev/shared';
import { setKeyspaceIsolation } from '@cbjsdev/vitest';

// TODO reproduce the segfault and get its stacktrace
describe('kv', { timeout: 5_000 }, () => {
  beforeAll(() => {
    setKeyspaceIsolation('per-test');
  }); 

  it('whatev', ({ expect }) => {
    expect(true).toBe(true);
  }); 

/*
  it('should isolate an insert', async ({ expect, getCluster }) => {
    const cluster = await getCluster();

    const collection = cluster.bucket('store').scope('library').collection('books');
    await collection.insert('docKey', {
      title: 'insert',
    }, { timeout: 10000 }); 

    const { content } = await collection.get('docKey');

    expect(content).toEqual({ title: 'insert' }); 
  }); 
*/

  it('should isolate a get', async ({ expect, getCluster }) => {
    const cluster = await getCluster();

    await expect(
      cluster.bucket('store').scope('library').collection('books').get('docKey', { timeout: 10000 })
    ).rejects.toThrowError();
  }); 

  it('should throw the original error', async ({ expect, getCluster }) => {
    const cluster = await getCluster();

    await cluster.bucket('store').scope('library').collection('books').insert('docKey', {
      title: 'test',
    }, { timeout: 10000 }); 

    await expect(
      cluster.bucket('store').scope('library').collection('books').insert('docKey', {
        title: 'error',
      }, { timeout: 10000 })
    ).rejects.toThrowError(DocumentExistsError);
  }); 
});

michaelreiche@C02C2172MD6V cbjs % git clone GitHub - cbjs-dev/cbjs: A modern Couchbase SDK for Node.js and TypeScript.

cd cbjs

nvm install && nvm use

git checkout vitest/keyspace-isolation

pnpm i

pnpm run build

CBPPLOGLEVEL=trace vitest --project=project:keyspace-isolation --run

Cloning into ‘cbjs’…

remote: Enumerating objects: 19057, done.

remote: Counting objects: 100% (4486/4486), done.

remote: Compressing objects: 100% (1383/1383), done.

remote: Total 19057 (delta 3064), reused 4392 (delta 2985), pack-reused 14571

Receiving objects: 100% (19057/19057), 15.82 MiB | 27.60 MiB/s, done.

Resolving deltas: 100% (12392/12392), done.

zsh: command not found: nvm

branch ‘vitest/keyspace-isolation’ set up to track ‘origin/vitest/keyspace-isolation’.

Switched to a new branch ‘vitest/keyspace-isolation’

WARN This project is configured to use v7.29.1 of pnpm. Your current pnpm is v9.0.6

Scope: all 12 workspace projects

Packages: +975

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Progress: resolved 1043, reused 952, downloaded 23, added 975, done

node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild: Running postinstall script, done in 440ms

node_modules/.pnpm/vue-demi@0.14.7_vue@3.4.26_typescript@5.2.2_/node_modules/vue-demi: Running postinstall script, done in 196ms

node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild: Running postinstall script, done in 723ms

node_modules/.pnpm/nx@18.3.4/node_modules/nx: Running postinstall script, done in 955ms

. prepare$ husky

└─ Done in 217ms

packages/n1ql-parser postinstall$ patch-package

│ patch-package 8.0.0

│ Applying patches…

│ antlr4@4.13.1-patch-1 :heavy_check_mark:

└─ Done in 408ms

packages/cbjs install$ node ./scripts/install.mjs 4.3.1

│ Downloading Couchbase binary https://registry.npmjs.org/@couchbase/couchbase-darwin-x64-napi/-/couchbase-darwin-x64-napi-4.3.1.tgz

│ Couchbase binary has been installed.

└─ Done in 706ms

devDependencies:

  • @trivago/prettier-plugin-sort-imports 4.3.0

  • @typescript-eslint/eslint-plugin 6.21.0 (7.7.1 is available)

  • @typescript-eslint/parser 6.21.0 (7.7.1 is available)

  • @vitest/coverage-v8 1.5.2

  • @vitest/runner 1.5.2

  • @vitest/ui 1.5.2

  • eslint 8.57.0 (9.1.1 is available)

  • eslint-config-prettier 9.1.0

  • eslint-plugin-jsdoc 48.0.5 (48.2.3 is available)

  • eslint-plugin-node 11.1.0

  • eslint-plugin-prettier 5.1.3

  • eslint-plugin-vitest 0.3.26 (0.5.4 is available)

  • husky 9.0.11

  • lerna 8.1.2

  • patch-package 8.0.0

  • pino 8.21.0 (9.0.0 is available)

  • prettier 3.2.5

  • tsup 8.0.2

  • typescript 5.2.2 (5.4.5 is available)

  • vite 5.2.10

  • vitest 1.5.2

Done in 16.6s

@cbjsdev/monorepo@1.0.0 build /Users/michaelreiche/cbj3/cbjs

lerna run --stream build --scope @cbjsdev/*

(node:44098) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.

(Use node --trace-deprecation ... to show where the warning was created)

lerna notice cli v8.1.2

lerna notice filter including “@cbjsdev/*”

lerna info filter [ ‘@cbjsdev/*’ ]

Lerna (powered by Nx) Running target build for 5 projects:

  • @cbjsdev/cbjs

  • @cbjsdev/http-client

  • @cbjsdev/n1ql-parser

  • @cbjsdev/shared

  • @cbjsdev/vitest

———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

@cbjsdev/shared:build

@cbjsdev/shared: > @cbjsdev/shared@1.6.1 build /Users/michaelreiche/cbj3/cbjs/packages/shared

@cbjsdev/shared: > tsc -p tsconfig.build.json

@cbjsdev/http-client:build

@cbjsdev/n1ql-parser:build

@cbjsdev/http-client: > @cbjsdev/http-client@1.6.1 build /Users/michaelreiche/cbj3/cbjs/packages/http-client

@cbjsdev/http-client: > tsc -p tsconfig.build.json

@cbjsdev/n1ql-parser: > @cbjsdev/n1ql-parser@1.1.3 build /Users/michaelreiche/cbj3/cbjs/packages/n1ql-parser

@cbjsdev/n1ql-parser: > tsc -p tsconfig.build.json

@cbjsdev/cbjs:build

@cbjsdev/cbjs: > @cbjsdev/cbjs@1.6.1 build /Users/michaelreiche/cbj3/cbjs/packages/cbjs

@cbjsdev/cbjs: > tsc -p tsconfig.build.json

@cbjsdev/vitest:build

@cbjsdev/vitest: > @cbjsdev/vitest@1.6.1 build /Users/michaelreiche/cbj3/cbjs/packages/vitest

@cbjsdev/vitest: > tsc -p tsconfig.build.json

———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

Lerna (powered by Nx) Successfully ran target build for 5 projects

zsh: command not found: vitest

michaelreiche@C02C2172MD6V cbjs % ./node_modules/.bin/vitest --project=project:keyspace-isolation --run

RUN v1.5.2 /Users/michaelreiche/cbj3/cbjs

(node:44324) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.

(Use node --trace-deprecation ... to show where the warning was created)

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

(node:44324) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1435ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1435ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1435ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10) 7233ms

✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2) 1435ms

❯ |project:keyspace-isolation| tests/kv.spec.ts (4) 5193ms

❯ kv (4) 5192ms

✓ whatev

✓ should isolate an insert 3794ms

× should isolate a get 1102ms

✓ should throw the original error

❯ |project:keyspace-isolation| tests/kv-no-isolation.spec.ts (1) 744ms

❯ kv-no-isolation (1) 741ms

× should throw the original error 741ms

✓ |project:keyspace-isolation| tests/test-without-suite.spec.ts (1)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

FAIL |project:keyspace-isolation| tests/kv-no-isolation.spec.ts > kv-no-isolation > should throw the original error

FAIL |project:keyspace-isolation| tests/kv.spec.ts > kv > should isolate a get

CouchbaseError: Unknown Couchbase error: Operation aborted.

❯ Module.errorFromCpp …/…/packages/cbjs/src/bindingutilities.ts:899:10

❯ …/…/packages/cbjs/src/cluster.ts:812:23

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Serialized Error: { context: undefined }

Caused by: Error: Operation aborted.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Serialized Error: { code: 89 }

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

Test Files 2 failed | 3 passed (5)

Tests 2 failed | 15 passed | 1 skipped (18)

Start at 10:57:53

Duration 21.59s (transform 1.26s, setup 1.16s, collect 30ms, tests 14.61s, environment 1ms, prepare 3.04s)

HTML Report is generated

You can run npx vite preview --outDir tests-report to see the test results.

michaelreiche@C02C2172MD6V cbjs %

Maybe there is an error in my code.

Your logs point to cluster.ts:812 which is the call to the c++ bindings for the connection and the error is CouchbaseError : Unknown Couchbase error: Operation aborted.

I’m pretty sure the c++ bindings are not context aware, which leads to this error.

I put a consol.log() at line 812 in cluster.ts
Looks like the mystery error is 89. I’m trying to figure out if that is 89 hex or decimal. And what it is and why it is “unknown”.

Apparently it is NO_COLLECTIONS_MANIFEST and should be retried.

        "89": {
            "name": "NO_COLLECTIONS_MANIFEST",
            "desc": "No collections manifest has been set.",
            "attrs": [
                "retry-later"
            ]
        }
% pnpx vitest --project=project:keyspace-isolation --run --disable-console-intercept --reporter=basic

**RUN** v1.5.3 /Users/michaelreiche/cbj3/cbjs

(node:52775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

(Use `node --trace-deprecation ...` to show where the warning was created)

✓ |project:keyspace-isolation| tests/keyspace-isolation-scope.spec.ts (10 tests) 8971ms

(node:52775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

(Use `node --trace-deprecation ...` to show where the warning was created)

[Error: Operation aborted.] { code: 89 }

✓ |project:keyspace-isolation| tests/keyspace-isolation-pool.spec.ts (2 tests | 1 skipped) 1863ms

(node:52775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

(Use `node --trace-deprecation ...` to show where the warning was created)

(node:52775) [DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.

(node:52775) [DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.

[Error: Operation aborted.] { code: 89 }

[Error: Operation aborted.] { code: 89 }

❯ |project:keyspace-isolation| tests/kv.spec.ts (4 tests | 2 failed) 5312ms

❯ tests/kv.spec.ts > kv > should isolate a get

→ Unknown Couchbase error: Operation aborted.

❯ tests/kv.spec.ts > kv > should throw the original error

→ Unknown Couchbase error: Operation aborted.

(node:52775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

(Use `node --trace-deprecation ...` to show where the warning was created)

[Error: Operation aborted.] { code: 89 }

❯ |project:keyspace-isolation| tests/kv-no-isolation.spec.ts (1 test | 1 failed) 1123ms

❯ tests/kv-no-isolation.spec.ts > kv-no-isolation > should throw the original error

→ Unknown Couchbase error: Operation aborted.

(node:52775) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.

(Use `node --trace-deprecation ...` to show where the warning was created)

✓ |project:keyspace-isolation| tests/test-without-suite.spec.ts (1 test) 3ms

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ **Failed Tests 3** ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

**FAIL** |project:keyspace-isolation| tests/kv-no-isolation.spec.ts > kv-no-isolation > should throw the original error

**FAIL** |project:keyspace-isolation| tests/kv.spec.ts > kv > should isolate a get

**FAIL** |project:keyspace-isolation| tests/kv.spec.ts > kv > should throw the original error

**CouchbaseError**: Unknown Couchbase error: Operation aborted.

❯ Module.errorFromCpp ../../packages/cbjs/src/bindingutilities.ts:899:10

❯ ../../packages/cbjs/src/cluster.ts:813:23

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

**Serialized Error:** { context: undefined }

**Caused by: Error**: Operation aborted.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

**Serialized Error:** { code: 89 }

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯

Test Files **2 failed** | **3 passed** (5)

Tests **3 failed** | **14 passed** | 1 skipped (18)

Start at 12:53:07

Duration 24.59s (transform 1.55s, setup 1.28s, collect 35ms, tests 17.27s, environment 1ms, prepare 2.79s)

Maybe skip the caching of this.clusterPromise in getCluster().

Without that caching, the error is scope_not_found. Which sounds about right.


 FAIL  |project:keyspace-isolation| tests/kv.spec.ts > kv > should isolate an insert
ScopeNotFoundError: scope not found
 ❯ Module.errorFromCpp ../../packages/cbjs/src/bindingutilities.ts:768:14
 ❯ Collection.insert ../../packages/cbjs/src/collection.ts:1130:19
 ❯ tests/kv.spec.ts:23:5
     21| 
     22|     const collection = cluster.bucket('store').scope('library').collection('books');
     23|     await collection.insert('docKey', {
       |     ^
     24|       title: 'insert',
     25|     }, {timeout: 5000});

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { context: { status_code: undefined, opaque: 8, cas: { raw: { '0': +0, '1': +0, '2': +0, '3': +0, '4': +0, '5': +0, '6': +0, '7': +0, constructor: 'Function<Buffer>', readBigUInt64LE: 'Function<readBigUInt64LE>', readBigUInt64BE: 'Function<readBigUInt64BE>', readBigUint64LE: 'Function<readBigUInt64LE>', readBigUint64BE: 'Function<readBigUInt64BE>', readBigInt64LE: 'Function<readBigInt64LE>', readBigInt64BE: 'Function<readBigInt64BE>', writeBigUInt64LE: 'Function<writeBigUInt64LE>', writeBigUInt64BE: 'Function<writeBigUInt64BE>', writeBigUint64LE: 'Function<writeBigUInt64LE>', writeBigUint64BE: 'Function<writeBigUInt64BE>', writeBigInt64LE: 'Function<writeBigInt64LE>', writeBigInt64BE: 'Function<writeBigInt64BE>', readUIntLE: 'Function<readUIntLE>', readUInt32LE: 'Function<readUInt32LE>', readUInt16LE: 'Function<readUInt16LE>', readUInt8: 'Function<readUInt8>', readUIntBE: 'Function<readUIntBE>', readUInt32BE: 'Function<readUInt32BE>', readUInt16BE: 'Function<readUInt16BE>', readUintLE: 'Function<readUIntLE>', readUint32LE: 'Function<readUInt32LE>', readUint16LE: 'Function<readUInt16LE>', readUint8: 'Function<readUInt8>', readUintBE: 'Function<readUIntBE>', readUint32BE: 'Function<readUInt32BE>', readUint16BE: 'Function<readUInt16BE>', readIntLE: 'Function<readIntLE>', readInt32LE: 'Function<readInt32LE>', readInt16LE: 'Function<readInt16LE>', readInt8: 'Function<readInt8>', readIntBE: 'Function<readIntBE>', readInt32BE: 'Function<readInt32BE>', readInt16BE: 'Function<readInt16BE>', writeUIntLE: 'Function<writeUIntLE>', writeUInt32LE: 'Function<writeUInt32LE>', writeUInt16LE: 'Function<writeUInt16LE>', writeUInt8: 'Function<writeUInt8>', writeUIntBE: 'Function<writeUIntBE>', writeUInt32BE: 'Function<writeUInt32BE>', writeUInt16BE: 'Function<writeUInt16BE>', writeUintLE: 'Function<writeUIntLE>', writeUint32LE: 'Function<writeUInt32LE>', writeUint16LE: 'Function<writeUInt16LE>', writeUint8: 'Function<writeUInt8>', writeUintBE: 'Function<writeUIntBE>', writeUint32BE: 'Function<writeUInt32BE>', writeUint16BE: 'Function<writeUInt16BE>', writeIntLE: 'Function<writeIntLE>', writeInt32LE: 'Function<writeInt32LE>', writeInt16LE: 'Function<writeInt16LE>', writeInt8: 'Function<writeInt8>', writeIntBE: 'Function<writeIntBE>', writeInt32BE: 'Function<writeInt32BE>', writeInt16BE: 'Function<writeInt16BE>', readFloatLE: 'Function<readFloatForwards>', readFloatBE: 'Function<readFloatBackwards>', readDoubleLE: 'Function<readDoubleForwards>', readDoubleBE: 'Function<readDoubleBackwards>', writeFloatLE: 'Function<writeFloatForwards>', writeFloatBE: 'Function<writeFloatBackwards>', writeDoubleLE: 'Function<writeDoubleForwards>', writeDoubleBE: 'Function<writeDoubleBackwards>', asciiSlice: 'Function<asciiSlice>', base64Slice: 'Function<base64Slice>', base64urlSlice: 'Function<base64urlSlice>', latin1Slice: 'Function<latin1Slice>', hexSlice: 'Function<hexSlice>', ucs2Slice: 'Function<ucs2Slice>', utf8Slice: 'Function<utf8Slice>', asciiWrite: 'Function<asciiWrite>', base64Write: 'Function<base64Write>', base64urlWrite: 'Function<base64urlWrite>', latin1Write: 'Function<latin1Write>', hexWrite: 'Function<hexWrite>', ucs2Write: 'Function<ucs2Write>', utf8Write: 'Function<utf8Write>', parent: { constructor: 'Function<ArrayBuffer>', byteLength: 8, slice: 'Function<slice>', maxByteLength: 8, resizable: false, resize: 'Function<resize>', transfer: 'Function<transfer>', transferToFixedLength: 'Function<transferToFixedLength>', detached: false }, offset: +0, copy: 'Function<copy>', toString: 'Function<toString>', equals: 'Function<equals>', inspect: 'Function<inspect>', compare: 'Function<compare>', indexOf: 'Function<indexOf>', lastIndexOf: 'Function<lastIndexOf>', includes: 'Function<includes>', fill: 'Function<fill>', write: 'Function<write>', toJSON: 'Function<toJSON>', subarray: 'Function<subarray>', slice: 'Function<slice>', swap16: 'Function<swap16>', swap32: 'Function<swap32>', swap64: 'Function<swap64>', toLocaleString: 'Function<toString>', BYTES_PER_ELEMENT: 1, buffer: { constructor: 'Function<ArrayBuffer>', byteLength: 8, slice: 'Function<slice>', maxByteLength: 8, resizable: false, resize: 'Function<resize>', transfer: 'Function<transfer>', transferToFixedLength: 'Function<transferToFixedLength>', detached: false }, byteLength: 8, byteOffset: +0, length: 8, entries: 'Function<entries>', keys: 'Function<keys>', values: 'Function<values>', at: 'Function<at>', copyWithin: 'Function<copyWithin>', every: 'Function<every>', filter: 'Function<filter>', find: 'Function<find>', findIndex: 'Function<findIndex>', findLast: 'Function<findLast>', findLastIndex: 'Function<findLastIndex>', forEach: 'Function<forEach>', join: 'Function<join>', map: 'Function<map>', reverse: 'Function<reverse>', reduce: 'Function<reduce>', reduceRight: 'Function<reduceRight>', set: 'Function<set>', some: 'Function<some>', sort: 'Function<sort>', toReversed: 'Function<toReversed>', toSorted: 'Function<toSorted>', with: 'Function<with>' }, toString: 'Function<toString>', toJSON: 'Function<toJSON>', constructor: 'Function<Cas>' }, key: undefined, bucket: undefined, collection: undefined, scope: undefined, context: '', ref: '', constructor: 'Function<KeyValueErrorContext>' } }
Caused by: Error: scope_not_found (16)

Also - this sounds like it might be a problem:

(node:64593) [DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.

@mreiche I have finally find the issue.

When you do cluster.bucket('foo'), it opens the bucket behind the scene, by calling the C++ bindings.

Because this operation is not awaited (see code), it is possible that you try to perform an operation towards a bucket that is not opened yet.

When that happens, the C++ client to queue your operation and retry every 500ms.
If you do an operation after the bucket has been opened but before those 500ms, this operation will go through immediately, not waiting the next 500ms tick.

During the tests, the bucket will be created, opened (opening would fail), insert would be tried and succeed, therefore the tests ends, triggering the destruction of the bucket. Then the 500ms tick kicks in, retries to open the bucket, which does not exist anymore, triggers an error.

When running a single test this does not happen, because the connection is closed, aborting pending operations.

This explains why adding a 200ms sleep did not solve the issue but adding a 500ms solved it : the connection was delayed by 500ms, so the test would not complete before the retry, therefore the retry would succeed before the test ends & the bucket was destroyed.

What I found interesting is that, after each test, the connection is closed. So why the pending operations would be retried ?
Reading the couchbase log I see :

[2024-05-02 17:10:36.793]    0ms [debu] [52009,588682] [5cf525-3bc7-e944-ed02-41700d38356314/98313a-fa22-2748-7b7b-38b38cf3dd7aa3/plain/-] <localhost/::1:11210> stop MCBP connection, reason=do_not_retry
[2024-05-02 17:10:36.793]    0ms [debu] [52009,588682] [5cf525-3bc7-e944-ed02-41700d38356314/98313a-fa22-2748-7b7b-38b38cf3dd7aa3/plain/-] <localhost/::1:11210> destroy MCBP connection

... later ...

[2024-05-02 17:10:37.184]    0ms [debu] [52009,588682] [5cf525-3bc7-e944-ed02-41700d38356314/043936-bca2-9e48-f4bf-f23683392514d9/plain/cbjs_b_342c566b] <localhost/::1:11210> unable to select bucket: cbjs_b_342c566b, probably the bucket does not exist
[2024-05-02 17:10:37.184]    0ms [debu] [52009,588682] all nodes failed to bootstrap, triggering DNS-SRV refresh, ec=bucket_not_found (10), last endpoint="localhost:11210"
[2024-05-02 17:10:37.184]    0ms [warn] [52009,588682] [5cf525-3bc7-e944-ed02-41700d38356314/043936-bca2-9e48-f4bf-f23683392514d9/plain/cbjs_b_342c566b] <localhost/::1:11210> failed to bootstrap session ec=bucket_not_found (10), bucket="cbjs_b_342c566b"
[2024-05-02 17:10:37.184]    0ms [debu] [52009,588682] [5cf525-3bc7-e944-ed02-41700d38356314/043936-bca2-9e48-f4bf-f23683392514d9/plain/cbjs_b_342c566b] <localhost/::1:11210> stop MCBP connection, reason=node_not_available
[2024-05-02 17:10:37.185]    0ms [debu] [52009,588682] Query DNS-SRV: address="localhost", service="_couchbase", nameserver="1.1.1.1:53"
[2024-05-02 17:10:37.185]    0ms [trac] [52009,588682] Query DNS-SRV (UDP) address="1.1.1.1:53", udp_timeout=250ms, total_timeout=500ms
[2024-05-02 17:10:37.185]    0ms [debu] [52009,588682] [5cf525-3bc7-e944-ed02-41700d38356314/043936-bca2-9e48-f4bf-f23683392514d9/plain/cbjs_b_342c566b] <localhost/::1:11210> destroy MCBP connection
[2024-05-02 17:10:37.196]   10ms [debu] [52009,588682] DNS UDP returned 0 records

As you can see, roughly 500ms later, it still retry the pending operations. Is this the expected behavior ? If so, how can I properly abort pending operation without killing the client altogether ?

During the tests, the bucket will be created, opened (opening would fail),

It shouldn’t fail. It should be retried for up to kvConnectionTimeout, which is 10 seconds by default. Unless you have it set to, say… 500ms (does that ring any bells? I don’t know if setting as a url query parameter works). Then it would fail.

Other SDKs have a waitUntilReady() method - which does exactly that. If you create a bucket, you can call waitUntilRead() to wait there until the bucket is ready to use (or throws a times-out waiting). I don’t know why nodejs doesn’t have it.

Because of the distributed nature of Couchbase - especially data nodes - it’s difficult to know when a bucket is “ready”. It might be ready on one node, but not on another. One node might have metadata for the bucket, but another node might not. Same with query indexes etc. Creating stuff and then using it right away has never been fun with Couchbase (recall the issue you opened for Spring Data Couchbase way back when).

retries to open the bucket, which does not exist anymore, triggers an error.

I suspect this is what triggers the 89 error. That during deletion of the bucket, the bucket is present, but no longer has a collections manifest. This shouldn’t trigger an error, it should simply not find the bucket and retry until timeout. But apparently the C++ library doesn’t handle 89. (The Java SDK treats 89 the same as ‘unknown bucket’).

after each test, the connection is closed.

Where is that done?

When I said it would fail, I mean it would not succeed on the first attempt and be scheduled for retry.

I have set a connectTimeout for the connection of CbjsTestRunner, but it is not involved in the issue. Just to be sure I have removed the option and it doesn’t have any effect.

The error code 89 probably comes from after the bucket deletion, not during.
About the error management, it should retry unless the connection has been closed. It should not re-open it to retry, which appears to be the current behavior, AFAICT.

In the method KeyspaceIsolationPool.dispose.