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

Handle errors when serializing logged objects in console plugin #760

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

ewoerner
Copy link
Contributor

When serialization of a value for console output using JSON.stringify() fails for any reason, use its toString() implementation as a fallback instead of throwing.

Closes #759

Copy link

github-actions bot commented Sep 17, 2024

🤖 Pull request artifacts

file commit
IITC_Mobile-test.apk a3e5e90
test-0.38.1.20241002.120504.zip a3e5e90

See build on website

@modos189
Copy link
Contributor

I observe that typing console.log(window) without and with a fix causes the browser to freeze.

After fixing in Chrome, after waiting for some time, the output is displayed correctly.
In Firefox in both cases the exception “Uncaught InternalError: too much recursion” occurs and the output is incorrect.

@xscreach
Copy link
Contributor

I observe that typing console.log(window) without and with a fix causes the browser to freeze.

After fixing in Chrome, after waiting for some time, the output is displayed correctly.
In Firefox in both cases the exception “Uncaught InternalError: too much recursion” occurs and the output is incorrect.

That's what i thought... the code is missing a catch... will comment where...

cache = null;
return value;
});
} finally {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There/here also needs to be a catch, otherwise the error thrown will continue until browser handles it.
The catch should also return something for the output...
Maybe smth like

} catch (e) {
  return "error rendering: " + String.valueOf(value);
}

... the idea is to output the message and string representation of that object which should output some nonsense like [[Object object]] - which is still less confusing that either error or empty/undefined value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, but more likely v = "error rendering: " + String.valueOf(v); just in case the dev used console.log(window, 42)

@le-jeu le-jeu self-requested a review September 18, 2024 15:11
@modos189 modos189 merged commit d36dc95 into IITC-CE:master Oct 17, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debug plugin causes console statements to throw
4 participants