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
Stage actor initialization suppresses original exception message #1823
Comments
Hey @1MateuszKruk, I tried to reproduce it in the following unit test: serenity-js/packages/core/spec/stage/Stage.spec.ts Lines 353 to 364 in 2876a74
It looks like the stack trace of the cause is correctly concatenated with the wrapping error:
However, if we know that the cause is correctly attached, but you don't see it, it most likely means that the cause message gets swallowed somewhere on the way. Would you be able to reproduce the error using one of the Serenity/JS project templates that most closely resembles your setup? Let's get to the bottom of this! |
Hey -- I run into the same issue. I'm using Playwright and I wondered if that could play a role in the swallowing of the original exception. @1MateuszKruk are you, by any chance, also using Playwright as a test runner? |
@jbpros - you're right, nice catch! It looks like error serialisation in Playwright Test removes information about the nested error. It's the serialisation that happens when Playwright Test passes the error stack trace from the worker to the main process, I think. I managed to reproduce it in a test, now we just need to figure out why that happens and how to fix it :-) |
Haha! That was quite a wild guess, tbh. Is Serenity using the Error#cause property? If so, is that what's getting lost by the Playwright serialiser? |
Hmm, not the Node 16 spec; Serenity/JS nested errors were introduced back in Node 12 times, so they should be modernised to use Even with that though, I'm not sure if Playwright Test supports |
OK, so it looks like the issue comes down to Playwright Test removing anything from the stack trace that's not a reference to a file system location:
So the next question is: Does Playwright support Error#cause property? |
And the answer is: no, Playwright doesn't support Error#cause. When I modified the test as follows: import { describe, it } from '@serenity-js/playwright-test';
describe('Playwright Test reporting', () => {
describe('A scenario', () => {
it('fails with a nested error', () => {
try {
throw new Error('Example nested error');
}
catch (error) {
throw new Error('Example configuration error', { cause: error })
}
});
});
}); I still got:
So, there is no information about the nested error. I think an optimal solution to this would be for:
I think it might be a significant change on the Playwright side since they rely heavily on embedding additional information like Playwright zones in the stack trace. It's worth asking, though. If that doesn't work, Serenity/JS could merge error messages from nested errors and embed them in the top-level error message. |
Hi,
When I was working on Actor set up, I have encountered few errors with external clients, but as they were inside Abilitiy initialization, I only get an error like this:
ConfigurationError: TestActor encountered a problem when preparing actor "Alice" for stage <stack trace>
The original exception message gets lost, making debugging it less convenient.
How to reproduce:
throw new Error("custom error message")
The text was updated successfully, but these errors were encountered: