-
Notifications
You must be signed in to change notification settings - Fork 283
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(connector-besu): do not crash if ledger unreachable - send HTTP 503 #3406
Comments
Looks like Orion isn't configured correctly in the UPDATE: I will create an issue to remove tessera, orion base images from the besu aio (besu mp has it and is used for private tx) |
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After Exponential back-off - the delay between retries is increasing exponentially with every retry. |
Let's say start with the run-transaction endpoint of the besu connector and do these things:
|
@ruzell22 I figured it out! The issue is deep within the web3 library itself that was causing the crashes. I pushed a commit to your branch with fixes that make it work so that it doesn't crash the entire nodejs process anymore when the connection is down to the ledger. The other issue with the code was that you were having the re-try logic in the catch block within the endpoint request handler and this was trying to modify the http headers after the response was sent which was another thing that was ALSO crashing the entire nodejs process (which is why seemingly none of my fixes worked at first that were targeted at the web3 library itself). So now the code is like this:
What I need you to do to finish the task:
To verify the changes you make, take a look at this snippet (that I'll also add to the cmd-api-server readme). You can use this to mount your local changes on the besu connector code into the api server container and then configure the api server to not install from the registry but instead import the local package you have on your file-system (this is what I used to verify my fixes instead of publishing to npm every time)
|
This came up during a discussion here and I thought it best to document it a little more thoroughly so that later it can be referenced for others as well: https://github.com/hyperledger/cacti/issues/3406#issuecomment-2299654552 Signed-off-by: Peter Somogyvari <[email protected]>
This came up during a discussion here and I thought it best to document it a little more thoroughly so that later it can be referenced for others as well: https://github.com/hyperledger/cacti/issues/3406#issuecomment-2299654552 Signed-off-by: Peter Somogyvari <[email protected]>
This came up during a discussion here and I thought it best to document it a little more thoroughly so that later it can be referenced for others as well: https://github.com/hyperledger/cacti/issues/3406#issuecomment-2299654552 Signed-off-by: Peter Somogyvari <[email protected]>
--------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Primary Changes --------------- 1. Yarn patch to [email protected] so that it does not crash nodejs process Without the catch block, the rejection is an unhandled rejection that bubbles up to the top of the callstack where NodeJS itself catches it and then crashes the entire process. (used to be that it just logged a warning but since some of the newer versions it crashes which allows us to find these bugs in our code / library's code) 2. It is returning a 503 instead of a 500 3. Added a static retry-after header value of 5 seconds 4. Added test case in test-ledger which has run-transaction at the end that is expected to give error 503 when the backing ledger is unavailable Fixes: hyperledger-cacti#3406 Co-authored-by: Peter Somogyvari <[email protected]> Signed-off-by: ruzell22 <[email protected]> Signed-off-by: Peter Somogyvari <[email protected]>
Description
Right now the API server will exit with a crash if the Besu connector receives a request and the backing ledger is not accessible.
Instead of a full-on crash, we need to treat this as a recoverable error and send back
HTTP 503 - Service Unavailable
with a Retry-After header with exponential backoff where it starts from 1 second and the doubles every re-try.
The easiest way to reproduce is to follow this guide and remove the part of the command from step 2 that binds the API server to the host machine's network:
--network=host \
https://github.com/hyperledger/cacti/tree/main/packages/cactus-plugin-ledger-connector-besu#testing-api-calls-with-the-container
Acceptance Criteria
The text was updated successfully, but these errors were encountered: