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

[Bug]: webContents.send() does not thrown a serialization error #41433

Open
3 tasks done
Rn145 opened this issue Feb 26, 2024 · 1 comment
Open
3 tasks done

[Bug]: webContents.send() does not thrown a serialization error #41433

Rn145 opened this issue Feb 26, 2024 · 1 comment
Assignees
Labels
29-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/

Comments

@Rn145
Copy link

Rn145 commented Feb 26, 2024

Preflight Checklist

Electron Version

29.0.1

What operating system are you using?

Windows

Operating System Version

Windows 10 22H2 19045.3693

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

When passing an argument to web content.send that is not subject to serialization, the exception 'Error: Failed to serialize arguments' should be caught.

try{
  window.webContents.send('CHANNEL_1', Symbol()) // thrown exception
}
catch(error){
  console.log('sucessful catched', error)
}

Actual Behavior

The exception is not returned from the function. Instead, this exception is output to the console without affecting the progress of the program, except that the rendering process receives nothing.

try{
  window.webContents.send('CHANNEL_1', Symbol()) // the exception is not thrown
}
catch(error){
  console.log('sucessful catched', error)
}

Testcase Gist URL

https://gist.github.com/Rn145/25493b427379ff70f089d731a9397c6a

Additional Information

I was trying to study this problem, and the first thing I did was go to study the Electron source code. I saw it there:

WebFrameMain.prototype.send = function (channel, ...args) {
  if (typeof channel !== 'string') {
    throw new TypeError('Missing required channel argument');
  }

  try {
    return this._send(false /* internal */, channel, args);
  } catch (e) {
    console.error('Error sending from webFrameMain: ', e);
  }
};

Later I came across this PR #31401 in which another error was discussed, but its temporary solution still remained in the code and intercepted all exceptions from _send().

@Rn145 Rn145 added the bug 🪲 label Feb 26, 2024
@Rn145 Rn145 changed the title [Bug]: webContents.send() does not thrown a serialization error exception [Bug]: webContents.send() does not thrown a serialization error Feb 27, 2024
@taniishkaaa
Copy link

hi, i might have a fix for this issue & I'd be happy to open a PR for the same but I'm facing an error while running the tests:
An error occurred inside the spec runner: Error: No valid out directory found; use one of Testing,Release,Default,Debug or set process.env.ELECTRON_OUT_DIR at Object.getOutDir (/home/tanishka/electron/script/lib/utils.js:57:9) at installSpecModules (/home/tanishka/electron/script/spec-runner.js:216:62) at main (/home/tanishka/electron/script/spec-runner.js:92:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I've tried reading the documentation but I haven't been able to fix this yet. Any advice on how I can resolve this?

@jkleinsc jkleinsc added has-repro-gist Issue can be reproduced with code at https://gist.github.com/ 29-x-y labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
29-x-y bug 🪲 has-repro-gist Issue can be reproduced with code at https://gist.github.com/
Projects
No open projects
Status: 👍 Does Not Block Stable
Development

No branches or pull requests

4 participants