We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using an arrow function under specific conditions and calling "this", the try - catch within the context cannot catch the error normally.
0.55
Ubuntu
No response
script.js:
export class DEMO { constructor() { this.any = '' } ok_demo = () => { const error_demo = () => { console.log('The problem will be triggered as long as any "this" is called.', this.any) }; try { throw(new Error("test1")) } catch (error) { console.log("this", this) console.log("error", error) console.log("error.message", error.message) } }; issue_demo = function () { const error_demo = () => { console.log('The problem will be triggered as long as any "this" is called.', this.any) }; try { throw(new Error("test2")) } catch (error) { console.log("this", this) console.log("error", error) console.log("error.message", error.message) } } } export default async () => { const demo = new DEMO(); await demo.ok_demo(); console.log('--------------------------------------------') await demo.issue_demo(); }
run:
k6 run script.js
You can see that the captured error is actually "this" itself.
output:
INFO[0000] this {"any":""} source=console INFO[0000] error {} source=console INFO[0000] error.message test1 source=console INFO[0000] -------------------------------------------- source=console INFO[0000] this {"any":""} source=console INFO[0000] error {} source=console INFO[0000] error.message test2 source=console
INFO[0000] this {"any":""} source=console INFO[0000] error {} source=console INFO[0000] error.message test1 source=console INFO[0000] -------------------------------------------- source=console INFO[0000] this {"any":""} source=console INFO[0000] error {"any":""} source=console INFO[0000] error.message undefined source=console
The text was updated successfully, but these errors were encountered:
codebien
No branches or pull requests
Brief summary
When using an arrow function under specific conditions and calling "this", the try - catch within the context cannot catch the error normally.
k6 version
0.55
OS
Ubuntu
Docker version and image (if applicable)
No response
Steps to reproduce the problem
script.js:
run:
You can see that the captured error is actually "this" itself.
Expected behaviour
output:
Actual behaviour
output:
The text was updated successfully, but these errors were encountered: