Flaky CI Failure: node-sdk DeviceSync — TypeError: Cannot read properties of undefined (reading 'messages')
Workflow: Test
Failed run: https://github.com/xmtp/libxmtp/actions/runs/29943331512
Commit: 3e10d5d
Failed jobs: test-node-sdk / Test (node-sdk) shard 1
Summary
One of the three DeviceSync tests in sdks/js/node-sdk/test/DeviceSync.test.ts failed with a TypeError: Cannot read properties of undefined (reading 'messages'). The test ran for ~14.5 seconds before failing, consistent with a timing/race condition. All 182 other tests in shard 1 passed.
Error Details
❯ test/DeviceSync.test.ts (3 tests | 1 failed) 14525ms
TypeError: Cannot read properties of undefined (reading 'messages')
Test Files 1 failed | 14 passed (15)
Tests 1 failed | 182 passed (183)
##[error]TypeError: Cannot read properties of undefined (reading 'messages')
error: recipe `test-node-sdk-ci` failed on line 37 with exit code 1
Analysis
The test file has three tests that call .messages() on conversation objects retrieved via getConversationById. The error means one of those calls was made on undefined — the lookup returned undefined rather than a valid conversation object. This is likely a race condition where the group isn't yet visible/synced on the second installation at assertion time.
The relevant patterns in the test file (lines 132, 151, 208):
const messagesBefore = await group2Before!.messages(); // line 132
const messagesAfter = await group2After!.messages(); // line 151
const messagesOnClient2 = await group2!.messages(); // line 208
The tests use expect(group2).not.toBeNull() as a guard, but getConversationById can return undefined (not null) if the sync hasn't completed, and not.toBeNull() does not catch undefined. The ! non-null assertion operator only satisfies TypeScript at compile time — at runtime it does nothing, so the .messages() call throws.
This is a test/code failure (not an infrastructure failure). The fix likely involves either using not.toBeNullOrUndefined() / not.toBeFalsy() as the guard, or adding more robust wait/retry logic before expecting the conversation to be visible on the second installation.
Reported by Flaky Failure Watcher
Flaky CI Failure: node-sdk DeviceSync — TypeError: Cannot read properties of undefined (reading 'messages')
Workflow: Test
Failed run: https://github.com/xmtp/libxmtp/actions/runs/29943331512
Commit: 3e10d5d
Failed jobs: test-node-sdk / Test (node-sdk) shard 1
Summary
One of the three
DeviceSynctests insdks/js/node-sdk/test/DeviceSync.test.tsfailed with aTypeError: Cannot read properties of undefined (reading 'messages'). The test ran for ~14.5 seconds before failing, consistent with a timing/race condition. All 182 other tests in shard 1 passed.Error Details
Analysis
The test file has three tests that call
.messages()on conversation objects retrieved viagetConversationById. The error means one of those calls was made onundefined— the lookup returnedundefinedrather than a valid conversation object. This is likely a race condition where the group isn't yet visible/synced on the second installation at assertion time.The relevant patterns in the test file (lines 132, 151, 208):
The tests use
expect(group2).not.toBeNull()as a guard, butgetConversationByIdcan returnundefined(notnull) if the sync hasn't completed, andnot.toBeNull()does not catchundefined. The!non-null assertion operator only satisfies TypeScript at compile time — at runtime it does nothing, so the.messages()call throws.This is a test/code failure (not an infrastructure failure). The fix likely involves either using
not.toBeNullOrUndefined()/not.toBeFalsy()as the guard, or adding more robust wait/retry logic before expecting the conversation to be visible on the second installation.Reported by Flaky Failure Watcher