Skip to content
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

fix: cover logs error for ws message #3392

Conversation

barbarosh
Copy link
Contributor

Some message from websocket contain error

{
  "id": 59,
  "jsonrpc": "2.0",
  "error": {
    "code": -32601,
    "message": "Subscriptions unsupported for this network"
  }
}

Which not present any where, just add console log for represent error for developer

Copy link

changeset-bot bot commented Oct 17, 2024

⚠️ No Changeset found

Latest commit: b8ff4f7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mergify mergify bot added the community label Oct 17, 2024
@mergify mergify bot requested a review from a team October 17, 2024 16:15
@steveluscher
Copy link
Collaborator

This is a good change. This does not of course solve the problem of the subscription system endlessly looping when it encounters an error like this. Consider this:

import { Connection } from '@solana/web3.js';
const connection = new Connection('https://api.devnet.solana.com');
connection.onAccountChange({ toBase58() { return '1'.repeat(31); }}, console.log);

This invalid pubkey will generate a JSON-RPC error:

Received JSON-RPC error calling `accountSubscribe` {
  args: [
    '1111111111111111111111111111111',
    { encoding: 'base64', commitment: 'finalized' }
  ],
  error: { code: -32602, message: 'Invalid Request: Invalid pubkey provided' }
}

But then the thing will loop forever, retrying the subscription endlessly.

The problem is that this API has no practical way to communicate subscription failure to the client. This has been fixed in @solana/web3.js@2.0.0 and will not be addressed in the 1.x line.

@steveluscher steveluscher changed the title Fix: cover logs error for ws message fix: cover logs error for ws message Oct 17, 2024
@steveluscher steveluscher merged commit e345937 into solana-labs:maintenance/v1.x Oct 17, 2024
5 of 6 checks passed
Copy link
Contributor

🎉 This PR is included in version 1.95.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@barbarosh
Copy link
Contributor Author

This is a good change. This does not of course solve the problem of the subscription system endlessly looping when it encounters an error like this. Consider this:

import { Connection } from '@solana/web3.js';
const connection = new Connection('https://api.devnet.solana.com');
connection.onAccountChange({ toBase58() { return '1'.repeat(31); }}, console.log);

This invalid pubkey will generate a JSON-RPC error:

Received JSON-RPC error calling `accountSubscribe` {
  args: [
    '1111111111111111111111111111111',
    { encoding: 'base64', commitment: 'finalized' }
  ],
  error: { code: -32602, message: 'Invalid Request: Invalid pubkey provided' }
}

But then the thing will loop forever, retrying the subscription endlessly.

The problem is that this API has no practical way to communicate subscription failure to the client. This has been fixed in @solana/web3.js@2.0.0 and will not be addressed in the 1.x line.

Thanks, for explanation, of course this changes just for notify developer what something wrong with subscribe, and I like about 2 version which fixes this behavior, will wait for stable release

Copy link
Contributor

github-actions bot commented Nov 4, 2024

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants