-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Remove use of electron.remote
#23
Conversation
I haven't reviewed the code yet, but make sure you do this. Because your above questions become moot when this is done. When used in the renderer, it would not accept any options. It would be configured in the main process. |
Good point. The PR does send the errors to I think it should be good to go now whenever you find the time to review. |
@sindresorhus one remaining issue is to address stripping out entities that can't be sent via the structured clone algorithm. I'm not sure what the best way to do that would be - perhaps you already have some solution in mind? |
What happens if a type is not supported? If you pass a value directly, it probably throws, but what if it's a property. I think Relevant: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm |
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "electron-unhandled", | |||
"version": "3.0.2", | |||
"version": "3.0.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never bump in a PR. That's up to the maintainers to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an oops from working across too many projects at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to submit a PR to reverse this or is it trivial enough to resolve when you determine the appropriate version for these changes?
Does the error have any I think the best way might be to just try/catch the IPC call, if it throws, check if it's because it couldn't be cloned, if so, try sending |
Bump |
Thanks for the bumb and sorry for the long delay on this. I can't believe it's been a month already, jeez. The priority level got nudged down on our end, but it's still on my radar. Unfortunately there's no try {
return ipcRenderer.invoke(ERROR_HANDLER_CHANNEL, ...args);
} catch (invokeErr) {
if (invokeErr.message === 'An object could not be cloned.') {
// v8.serialize stuff
}
} I'd hope that the
This is probably a stupid question, but how can we iterate over the properties of an error object? We also need some new code for the I'm thinking we add a preload script like: const { logError } = require('./')
logError(Symbol()); // Symbols cannot be sent with the structured clone algorithm |
Could
The standard error properties are not enumerable for some dumb reason. So you need to manually get |
Friendly bump :) |
Friendly thank you! Too easy to take on too many projects. I don't think that we have to check that the message is equal to Because If we could be sure the value would be an error it would be pretty trivial though I think - or maybe I'm just overthinking this. So how about code like to cludge the values into an error format? const {serialize} = require('v8');
const tryMakeSerialized = arg => {
try {
const serialized = serialize(arg);
if (serialized) return serialized;
} catch {}
}
// ....
invokeErrorHandler = async (title, error) => {
try {
await ipcRenderer.invoke(ERROR_HANDLER_CHANNEL, title, error);
return;
} catch (invokeErr) {
if (invokeErr.message === 'An object could not be cloned.') {
error = ensureError(error)
const serializable = {
name: tryMakeSerialized(error.name),
message: tryMakeSerialized(error.message),
stack: tryMakeSerialized(error.stack),
};
ipcRenderer.invoke(ERROR_HANDLER_CHANNEL, title, serializable); // Invoke the error handler again with only the serializable values
}
}
} |
Yeah, let's try that and we can see how it works in practice. |
@sindresorhus we should be good to go - but because of the IPC back and forth, different contexts, and error-inception, this has been kind of hard to reason about and I can't guarantee these changes are entirely free of mistake. That said, I've been using our branch in development for the past 6 months or so without issue - although of course I just pushed some new commits that do change things a bit, and our use case will never trigger the structured clone/serialization failure in any event. I deemed this line to be removable without affecting functionality testing as any error invoked via the Also, it shouldn't be relevant since you'll be bumping the version anyway when ready to release - but a reminder that I accidentally bumped the version of Let me know if you see anything that needs to be addressed! |
This still needs docs updates. For example, that |
And CI is failing. |
You also have a weird change to |
I had found it strange that the project didn't use ESLint. I now see that |
Bump |
Thanks for the bump @sindresorhus. Got COVID, so things got set back even more. Working on this now though.
I think all options can only be configured from the The Lines 76 to 79 in 10680d8
Edit: Also, I suppose these lines are now useless: Lines 147 to 149 in c452122
|
@sindresorhus can you approve the workflow checks to run so I can see what had been failing? I think it was just linting issues, like missing semicolons, but without something like a |
@sindresorhus I believe this is good to go besides my pending review above regarding the name of the error variable in the |
Thanks :) |
There's a few things that remain issues here.
main
.logError
is. Just an explicit method a user can use to log an error, leveraging the configuration of electron-unhandled?Fixes #22