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

[BUG]: Learn How to Interact with On-Chain Programs - Step 43 - 44 - crash on code with errors #74

Open
gikf opened this issue Dec 17, 2022 · 4 comments
Labels
patch This issue/PR results in a patch release type: bug Something isn't working

Comments

@gikf
Copy link
Member

gikf commented Dec 17, 2022

Issue/Experience

During the run of tests on steps 43 and 44, server crashes if code has errors.

I had missing correct object creation when initially tried to run tests on step 43. This resulted in a crash:

Error 4XX - 5XX
Client has disconnected from local server

Terminal output is included below.

The same error doesn't create issues elsewhere, I've tried in step 35 making similar error and there were no crashes. It's not specific for only that error, crash happens also ie. on ReferenceError. Similar situation is with step 44.

🔵 INFO:  2022-12-17 15:15:18 Listening on port 8080
🔵 INFO:  2022-12-17 15:15:19 Watching for file changes on /workspace/solana-curriculum
undefined:33
  const instruction = TransactionInstruction(transaction);
                      ^

TypeError: Class constructor TransactionInstruction cannot be invoked without 'new'
    at sayHello (eval at <anonymous> (eval at <anonymous> (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:93:35)), <anonymous>:33:23)
    at eval (eval at <anonymous> (eval at <anonymous> (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:93:35)), <anonymous>:36:1)
    at eval (eval at <anonymous> (eval at <anonymous> (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:93:35)), <anonymous>:38:3)
    at eval (eval at <anonymous> (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:93:35), <anonymous>:35:13)
    at eval (eval at <anonymous> (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:93:35), <anonymous>:44:3)
    at file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:93:35
    at Array.map (<anonymous>)
    at runTests (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/test.js:79:43)
    at async FSWatcher.<anonymous> (file:///workspace/solana-curriculum/.freeCodeCamp/tooling/hot-reload.js:51:9)

Node.js v18.12.1

Output of running node tooling/camper-info.js from the workspace root

🔵 INFO: Project: learn-how-to-interact-with-on-chain-programs
🔵 INFO: Lesson Number: 1
🔵 INFO: Curriculum Version: 0.1.2
🔵 INFO: freeCodeCamp - Courses: [email protected]
🔵 INFO: Commit: 5526f1a chore(deps): update dependency @types/node to v18.11.13

🔵 INFO: OS Info:
Architecture: x64
Platform: linux
Release: 5.15.0-56-generic
Type: Linux

@ShaunSHamilton ShaunSHamilton added type: bug Something isn't working patch This issue/PR results in a patch release labels Dec 17, 2022
@ShaunSHamilton
Copy link
Member

I have looked into this quite a bit.

My issue is everything is wrapped in a try...catch. So, how any error can result in the server crashing, I cannot fathom.

@gikf
Copy link
Member Author

gikf commented Feb 11, 2023

I think I tracked the place where it's uncaught to the sayHello call in the code, which is then evaled.


Chaining .catch to it, stops the crash, and the exact TypeError is caught there. Or changing evaled function to async and awaiting both for sayHello and eval.

@ShaunSHamilton
Copy link
Member

Right, but the code that runs that block is within a try...catch:

const testPromises = hintsAndTestsArr.map(async ([hint, testCode], i) => {
if (beforeEach) {
try {
logover.debug('Starting: --before-each-- hook');
const _beforeEachOut = await eval(
`(async () => { ${beforeEach} })();`
);
logover.debug('Finished: --before-each-- hook');
} catch (e) {
logover.error('--before-each-- hook failed to run:');
logover.error(e);
}
}

In fact, it is within multiple try...catch blocks

@gikf
Copy link
Member Author

gikf commented Feb 12, 2023

I don't understand why exactly that's happening. Every time I encounter error handling in nested asynchronous function I feel I'm getting deeper and deeper into confusion. It almost appears as if when it's not caught at the nearest/first possible place then it ends up in some limbo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch This issue/PR results in a patch release type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants