-
Notifications
You must be signed in to change notification settings - Fork 336
fix(solana-utils): lazy-load jito-ts so non-Jito consumers don't crash #3702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,5 +81,5 @@ | |
| }, | ||
| "type": "module", | ||
| "types": "./dist/cjs/index.d.ts", | ||
| "version": "0.6.0" | ||
| "version": "0.6.1" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 Lock file not updated after version bump The version was bumped from Was this helpful? React with 👍 or 👎 to provide feedback. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Regression test for https://github.com/pyth-network/pyth-crosschain/issues/1838. | ||
| // | ||
| // `jito.ts` historically eager-imported `jito-ts/dist/sdk/block-engine/{searcher,types}`, | ||
| // which transitively required `jito-ts`'s nested `@solana/web3.js@~1.77.3` -> | ||
| // `rpc-websockets/dist/lib/client` — a path removed in `rpc-websockets@>=7.11`. | ||
| // Consumers that loaded any `@pythnetwork/solana-utils` export therefore | ||
| // crashed with `Cannot find module 'rpc-websockets/dist/lib/client'`, even | ||
| // when they never used the Jito helpers. | ||
| // | ||
| // We now type-only-import `SearcherClient`/`Bundle` and dynamic-import | ||
| // `Bundle` inside `sendTransactionsJito`. This test guards that contract. | ||
|
|
||
| describe("jito-ts lazy loading", () => { | ||
| it("does not load jito-ts when importing transaction helpers", async () => { | ||
| await import("../transaction"); | ||
|
|
||
| const cachedJitoPath = Object.keys(require.cache).find((p) => | ||
| p.includes(`${"/node_modules/"}jito-ts/`), | ||
| ); | ||
|
|
||
| expect(cachedJitoPath).toBeUndefined(); | ||
| }); | ||
|
|
||
| it("does not load jito-ts when importing jito.ts itself", async () => { | ||
| await import("../jito"); | ||
|
|
||
| const cachedJitoPath = Object.keys(require.cache).find((p) => | ||
| p.includes(`${"/node_modules/"}jito-ts/`), | ||
| ); | ||
|
|
||
| expect(cachedJitoPath).toBeUndefined(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 Dependencies use pinned version ranges instead of catalog references
The REVIEW.md states "For TypeScript dependencies, prefer using
catalog:versions over declaring package-specific dependency versions." Several dependencies in this package use explicit version ranges (e.g.,@coral-xyz/anchor: ^0.29.0,@solana/web3.js: ^1.90.0,bs58: ^5.0.0) while the pnpm workspace catalog defines versions for some of these (e.g.,@coral-xyz/anchor: ^0.30.1,@solana/web3.js: ^1.98.0,bs58: ^6.0.0). This is a pre-existing issue not introduced by this PR, but it's worth noting the divergence — the package uses older version ranges than what the catalog specifies.Was this helpful? React with 👍 or 👎 to provide feedback.