hop-protocol/hop

ERR_INTERNAL_ASSERTION / hop sdk fetchConfigFromS3 error: Error: fetchJsonOrThrow

mindrunner opened this issue · 7 comments

I see our backend process crashing wiht the following error message. This does not happen when hop integration is disabled.

I suspect a bug in hop SDK. Happy to assist figuring out what's going on.

Could not reproduce locally, only happens in high-load situations.

hop sdk fetchConfigFromS3 error: Error: fetchJsonOrThrow error: The user aborted a request.                                                               
    at fetchJsonOrThrow (/usr/src/app/node_modules/.pnpm/@hop-protocol+sdk@0.0.1-beta.573/node_modules/@hop-protocol/sdk/dist/src/utils/fetchJsonOrThrow.j
    at processTicksAndRejections (node:internal/process/task_queues:95:5)                                                                                 
    at runNextTicks (node:internal/process/task_queues:64:3)                                                                                              
    at listOnTimeout (node:internal/timers:540:9)                                                                                                         
    at process.processTimers (node:internal/timers:514:7)                                                                                                 
    at async HopBridge.fetchIpfsCoreConfigData (/usr/src/app/node_modules/.pnpm/@hop-protocol+sdk@0.0.1-beta.573/node_modules/@hop-protocol/sdk/dist/src/B
    at async HopBridge.fetchCoreConfigDataWithIpfsFallback (/usr/src/app/node_modules/.pnpm/@hop-protocol+sdk@0.0.1-beta.573/node_modules/@hop-protocol/sd
    at async HopBridge.fetchConfigFromS3 (/usr/src/app/node_modules/.pnpm/@hop-protocol+sdk@0.0.1-beta.573/node_modules/@hop-protocol/sdk/dist/src/Base.js
    at async HopBridge.getFeeBps (/usr/src/app/node_modules/.pnpm/@hop-protocol+sdk@0.0.1-beta.573/node_modules/@hop-protocol/sdk/dist/src/Base.js:582:9) 
    at async Promise.all (index 2)                                                                                                                        
    at async HopBridge.getSendData (/usr/src/app/node_modules/.pnpm/@hop-protocol+sdk@0.0.1-beta.573/node_modules/@hop-protocol/sdk/dist/src/HopBridge.js:
    at async exports.getTransferQuote.promise (/usr/src/app/services/tools/bridges/hop/hop.js:211:22)                                                     
Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.                                        
Please open an issue with this stack trace at https://github.com/nodejs/node/issues                                                                       
                                                                                                                                                          
    at assert (node:internal/assert:14:11)                                                                                                                
    at internalConnectMultiple (node:net:1118:3)                                                                                                          
    at Timeout.internalConnectMultipleTimeout (node:net:1687:3)                                                                                           
    at listOnTimeout (node:internal/timers:575:11)                                                                                                        
    at process.processTimers (node:internal/timers:514:7) {                                                                                               
  code: 'ERR_INTERNAL_ASSERTION'                                                                                                                          
} 

Hey @mindrunner what node version are you using?

You can try running node with this option as suggested in this node issue:

NODE_OPTIONS="--no-network-family-autoselection"

or try upgrading to the latest version of node 20.10.0 to see if that helps.

Seems like network_family_autoselection was made to be true by default in node v20 and causes the ERR_INTERNAL_ASSERTION issue with node for a lot of people.

The internal error seems to be thrown by the native node fetch function so it's been hard to debug the root cause.

I suspected a Node 20 issue as well, since we just recently made the upgrade. Will test the suggested fixes next week and report back!

Thanks @miguelmota!!

Btw, not directly related, but it would be nice to let the user chose the web requests library, similar to here: paraswap/paraswap-sdk#161

I prefer to not use fetch for multiple reasons and would like to use our own http client implementation.

@mindrunner good suggestion! Definitely doable

Cool, looking forward to that! :)

Btw, we are on node 20.10.0 already and facing the above mentioned issue.

@mindrunner thanks for reporting back on the node version. Curious, did the node option flag work?

Not under heavy load currently, but also did not see one crash so far. I consider it solved for now :) Thanks for helping