Skip to content

Conversation

@jochem-brouwer
Copy link
Member

At the RC releases PR #3886 which only updated package.jsons, changelogs, readmes and package-lock, for some reason when running client in tsx mode (so npm run client:start:ts) the Fetcher client/src/sync/fetcher/fetcher.ts would throw:

TypeError: Cannot read properties of undefined (reading 'pipes')
    at Readable.pipe (node:internal/streams/readable:670:13)
    at BlockFetcher.write (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/fetcher/fetcher.ts:500:8)
    at BlockFetcher._fetch (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/fetcher/fetcher.ts:519:12)
    at BlockFetcher.fetch (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/fetcher/fetcher.ts:552:32)
    at BlockFetcher.blockingFetch (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/fetcher/fetcher.ts:558:55)
    at FullSynchronizer.syncWithFetcher (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/sync.ts:149:29)
    at FullSynchronizer.sync (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/sync.ts:184:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at FullSynchronizer.start (/home/jochem/Documents/ejs/ethereumjs-monorepo/packages/client/src/sync/sync.ts:125:9)
[03-28|10:21:28] ERROR Received sync error, stopping sync and clearing fetcher: Cannot read properties of undefined (reading 'pipes')

This does NOT happen when running in npm run client:start:js. It also does not happen if you attach a debugger, tsx --inspect-brk bin/cli.ts

For some reason the RC releases have changed something in the specific tsx run. I think it would take the field _readableState which is marked as private on the Fetcher and somehow overwrite this value in the constructor of the Fetcher. This breaks the entire Readable object. The workaround (for now) is to cast this as any and query the fields which we need (should likely find a way to get the same result but not reading private properties of Readable).

This fix allows the client to start syncing!

I still do not know what the npm run client:start:ts (this runs tsx bin/cli.ts) does different than if I attach a debugger. How come the end result is different? Without this change, in the constructor of Fetcher, log console.log(this) after super( and one will see that almost the entire object is empty instead of having an initialized Readable 🤔

this.DEBUG &&
this.debug(
`Readable state length=${this._readableState!.length} exceeds max queue size=${
`Readable state length=${(<any>this)._readableState!.length} exceeds max queue size=${
Copy link
Member Author

@jochem-brouwer jochem-brouwer Mar 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work if _readableState is undefined, and if we cast as ! it will definitely error if it is undefined 🤔

(did not change this logic, just entered an any here)

@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 79.61%. Comparing base (ebea878) to head (f758380).
Report is 1 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

Flag Coverage Δ
block 83.29% <ø> (ø)
blockchain 89.49% <ø> (ø)
client 68.09% <60.00%> (+<0.01%) ⬆️
common 98.49% <ø> (ø)
devp2p 86.59% <ø> (ø)
evm 72.94% <ø> (ø)
genesis 99.98% <ø> (ø)
mpt 89.40% <ø> (-0.36%) ⬇️
rlp 91.43% <ø> (ø)
statemanager 69.16% <ø> (ø)
tx 90.58% <ø> (ø)
util 81.96% <ø> (ø)
vm 57.20% <ø> (ø)
wallet 88.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jochem-brouwer jochem-brouwer marked this pull request as ready for review March 28, 2025 13:32
Copy link
Contributor

@acolytec3 acolytec3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acolytec3 acolytec3 merged commit 9ee4e87 into master Mar 28, 2025
39 of 41 checks passed
@acolytec3 acolytec3 deleted the fix-tsx-client-fetch branch March 28, 2025 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants