PythonMonkey icon indicating copy to clipboard operation
PythonMonkey copied to clipboard

Add uncaughtExceptionHandler

Open Xmader opened this issue 2 years ago • 12 comments

This PR replaces https://github.com/Distributive-Network/PythonMonkey/pull/114 for the uncaughtExceptionHandler

Xmader avatar Aug 02 '23 06:08 Xmader

Hold on. Despite the CI passes, I've found some bugs need to be addressed.

Xmader avatar Aug 04 '23 19:08 Xmader

Hold on. Despite the CI passes, I've found some bugs need to be addressed.

Xmader avatar Aug 04 '23 19:08 Xmader

Hi @Xmader what is the status of this PR?

wesgarland avatar Mar 10 '24 01:03 wesgarland

Hi @Xmader what is the status of this PR?

wesgarland avatar Mar 10 '24 01:03 wesgarland

This PR was put on hold because there were bugs in the event-loop code. Let me see if the bugs have already been fixed.

Xmader avatar May 08 '24 19:05 Xmader

This PR was put on hold because there were bugs in the event-loop code. Let me see if the bugs have already been fixed.

Xmader avatar May 08 '24 19:05 Xmader

~~@wesgarland Is this PR needed for the v1.0 release?~~

uncaughtExceptionHandler is indeed needed for situations like

async function main() {
  throw new TypeError("abc")
}

main()

Prints out

Uncaught Error: Python SpiderMonkeyError: Error in file xxx.js, on line y, column z:
TypeError: abc
Stack Trace:
  ...

Xmader avatar May 08 '24 21:05 Xmader

There is still a problem that needs to be addressed (maybe in a separate PR).

new Promise(function (resolve, reject) 
{
  reject(new Error('abc'));
});

new Promise(function (resolve, reject) 
{
});

Expected:

Uncaught Error: abc
    @xxx.js:3:10
    @xxx.js:1:1

Actual: The program exits normally with exit code 0.

Xmader avatar May 15 '24 07:05 Xmader

There is still a problem that needs to be addressed (maybe in a separate PR).

new Promise(function (resolve, reject) 
{
  reject(new Error('abc'));
});

new Promise(function (resolve, reject) 
{
});

Expected:

Uncaught Error: abc
    @xxx.js:3:10
    @xxx.js:1:1

Actual: The program exits normally with exit code 0.

Xmader avatar May 15 '24 07:05 Xmader

The changes in 1bcb1f85f1c4ad3a2264e37732733f043d85fb6b...28dcb36595f7e3c7e6eec8887395d556b0d50e7e are to make the program print the actual JS error than a double-wrapped SpiderMonkeyError.

From

Uncaught Error: Python SpiderMonkeyError: Error in file xxx.js, on line y, column z:
TypeError: abc
Stack Trace:
  [email protected]:x:y

To barely

Uncaught TypeError: abc
    [email protected]:x:y

Xmader avatar May 15 '24 08:05 Xmader

The changes in 1bcb1f85f1c4ad3a2264e37732733f043d85fb6b...28dcb36595f7e3c7e6eec8887395d556b0d50e7e are to make the program print the actual JS error than a double-wrapped SpiderMonkeyError.

From

Uncaught Error: Python SpiderMonkeyError: Error in file xxx.js, on line y, column z:
TypeError: abc
Stack Trace:
  [email protected]:x:y

To barely

Uncaught TypeError: abc
    [email protected]:x:y

Xmader avatar May 15 '24 08:05 Xmader

What does the latest comment refer to?

If I run

new Promise(function (resolve, reject) { reject(new Error('abc')); });

I get

Promise { Error: abc @/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:3:10 @/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:1:1 replEval@/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py:128:16 }

If I run async function main() { throw new TypeError("abc") }

main()

I get

Promise { TypeError: abc main@/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:2:9 @/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:1:1 replEval@/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py:128:16 }

For the first one is there a missing call? Please clarify, please make your examples super clear

philippedistributive avatar May 15 '24 15:05 philippedistributive

What does the latest comment refer to?

If I run

new Promise(function (resolve, reject) { reject(new Error('abc')); });

I get

Promise { Error: abc @/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:3:10 @/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:1:1 replEval@/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py:128:16 }

If I run async function main() { throw new TypeError("abc") }

main()

I get

Promise { TypeError: abc main@/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:2:9 @/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py line 128 > eval:1:1 replEval@/home/philippe/Sources/PythonMonkey/python/pythonmonkey/cli/pmjs.py:128:16 }

For the first one is there a missing call? Please clarify, please make your examples super clear

philippedistributive avatar May 15 '24 15:05 philippedistributive

Please add some explicit tests for the new exception catching and reporting

philippedistributive avatar May 15 '24 15:05 philippedistributive

Please add some explicit tests for the new exception catching and reporting

philippedistributive avatar May 15 '24 15:05 philippedistributive

For the first one is there a missing call? Please clarify, please make your examples super clear

You'll need to put the whole thing into a js file and run it with pmjs.

Xmader avatar May 15 '24 16:05 Xmader

For the first one is there a missing call? Please clarify, please make your examples super clear

You'll need to put the whole thing into a js file and run it with pmjs.

Xmader avatar May 15 '24 16:05 Xmader

For the first one is there a missing call? Please clarify, please make your examples super clear

You'll need to put the whole thing into a js file and run it with pmjs.

Please provide details right here. What whole thing from above? I tried putting some of it in a file and when run there was no output. Let's be precise and explicit. Make it easy for your reviewer

philippedistributive avatar May 15 '24 16:05 philippedistributive

For the first one is there a missing call? Please clarify, please make your examples super clear

You'll need to put the whole thing into a js file and run it with pmjs.

Please provide details right here. What whole thing from above? I tried putting some of it in a file and when run there was no output. Let's be precise and explicit. Make it easy for your reviewer

philippedistributive avatar May 15 '24 16:05 philippedistributive

@philippedistributive when run there was no output

That's correct. It's expected to be an error but it exited normally without any error output. I should make it more clear by adding a console.log

Xmader avatar May 15 '24 21:05 Xmader

@philippedistributive when run there was no output

That's correct. It's expected to be an error but it exited normally without any error output. I should make it more clear by adding a console.log

Xmader avatar May 15 '24 21:05 Xmader

https://github.com/Distributive-Network/PythonMonkey/pull/156#issuecomment-2112867758 remains

philippedistributive avatar May 15 '24 23:05 philippedistributive

@philippedistributive when run there was no output

That's correct. It's expected to be an error but it exited normally without any error output. I should make it more clear by adding a console.log

Now works

Xmader avatar May 28 '24 07:05 Xmader

Also works for errors thrown in async functions

image

Xmader avatar May 28 '24 07:05 Xmader

Also works for errors thrown in async functions

image

Xmader avatar May 28 '24 07:05 Xmader

@philippedistributive https://github.com/Distributive-Network/PythonMonkey/pull/156#issuecomment-2112867758 done

Xmader avatar May 29 '24 01:05 Xmader

@philippedistributive https://github.com/Distributive-Network/PythonMonkey/pull/156#issuecomment-2112867758 done

Xmader avatar May 29 '24 01:05 Xmader

@Xmader what do you make of the failed test?

philippedistributive avatar Jun 03 '24 19:06 philippedistributive

@Xmader what do you make of the failed test?

philippedistributive avatar Jun 03 '24 19:06 philippedistributive

@Xmader what do you make of the failed test?

The failed tests may be related to https://github.com/Distributive-Network/PythonMonkey/pull/353. It segfaults on test_strings.py. https://github.com/Distributive-Network/PythonMonkey/actions/runs/9353575587/job/25744630014?pr=156#step:13:162

Xmader avatar Jun 03 '24 19:06 Xmader

@Xmader what do you make of the failed test?

The failed tests may be related to https://github.com/Distributive-Network/PythonMonkey/pull/353. It segfaults on test_strings.py. https://github.com/Distributive-Network/PythonMonkey/actions/runs/9353575587/job/25744630014?pr=156#step:13:162

Xmader avatar Jun 03 '24 19:06 Xmader