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
ts: Program upgrade event crashes existing listeners #1685
Comments
@paul-schaaf I think this should be considered as a bug, because it crashes whole program and you can't catch this exception. Also, I can make PR if it's okay. |
Created pull request #1730 |
Could you post the logs that you received or a minimal reproducibl example? |
Yes, of course. I've added tests for it in the pull request, but will copy it here:
The log that get's printed after program upgrade is: Edit: Also, I think node program should not crash if some unexpected log got somehow in the events log, that's why I thought handling it outside was better idea. |
So after you upgrade a program, all logs start with |
am looking at the solana core code. That doesnt seem to happen. So looks like I am misunderstanding. Could you provide a program or describe a flow so I can build one so I can run it myself to get that error? |
Hello, Here you can view two such transactions: 1. program upgrade transaction It happens on upgrade of any program.
@paul-schaaf Do you think it's better to change regExp for log-parsing to also handle these types of events in client library? |
@dfl-grisha yes the library should be handle to handle all solana logs. It should never error |
Should we fire some custom event when program upgrade occurs? |
Also right now event parser assumes that the first line of transaction logs starts with the prefix |
@paul-schaaf If this solution is okay, I will make PR. We just removed constructor of We've added tests to make sure, that it works as intended. |
hello @armaniferrante, |
@dfl-zeke yes that solution looks good to me. It would be great if you could add another test that just checks the normal case where there the logs dont start with "Upgraded Program". |
Yes, sure! I'll add more tests and do PR! |
So, we have custom event inside our program and appropriate listener in our client. Problem is that when we upgrade our program (or run
anchor test
) our client program crashes and gives us following error:So when we upgrade program, following regex fails
/^Program (.*) invoke.*$/g
, because log starts with:Upgraded program ****
and causes our client to crash.Class name is ExecutionContext where this regex is used. We can fix it by simply wrapping creation of this class in try/catch, but there could be better solutions, because we don't want to change it inside node_modules
Our client code:
The text was updated successfully, but these errors were encountered: