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

QUIC client breaks inside electron #121

Open
lukasrakauskas opened this issue Jul 17, 2024 · 2 comments
Open

QUIC client breaks inside electron #121

lukasrakauskas opened this issue Jul 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@lukasrakauskas
Copy link

lukasrakauskas commented Jul 17, 2024

Describe the bug

Electron has dropped support for external buffers. Thus some methods that this quic library uses are not working in such environment.

Error: Create external arraybuffer failed
    at get connectionId (/Users/lukas.rakauskas/dev/electron-js-quic-reproduce/node_modules/@matrixai/quic/dist/QUICConnection.js:326:36)
    at QUICClient.createQUICClient (/Users/lukas.rakauskas/dev/electron-js-quic-reproduce/node_modules/@matrixai/quic/dist/QUICClient.js:148:45)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'Unknown'
}

To Reproduce

I've made a reproduce repo. To reproduce pull it run npm install and npm run start
https://github.com/lukasrakauskas/electron-js-quic-reproduce

Expected behavior

QUIC client should be able to connect to a server, read and write to streams when created within electron.

Platform

  • Device: Macbook M1 Pro
  • OS: macOS Sonoma 14.5

Possible fix

The failing point is reading source ID in javascript, converting Uint8array to external vec seems to solve the external array buffer problem.

// src/native/napi/connection.rs

#[napi]
pub fn source_id(&self) -> External<Vec<u8>> {
  let source_id = self.0.source_id();
  let bytes = source_id.as_ref().to_vec();
  External::new(bytes) 
}

After this, the js fails to read header dcid property that also is Uint8array. To solve this, I've added get_dcid method to Header struct to be used instead of reading dcid directly.

// src/native/napi/packet.rs

#[napi]
pub fn get_dcid(&self) -> External<Vec<u8>> {
  External::new(self.dcid.to_vec()) 
}

Finally the library started to work for my use case

@lukasrakauskas lukasrakauskas added the bug Something isn't working label Jul 17, 2024
Copy link

linear bot commented Jul 17, 2024

@CMCDragonkai
Copy link
Member

Thanks for reporting this @lukasrakauskas. I'm going to be honest with you here, our company doesn't have the bandwidth to fix this atm, we're focusing on other aspects of our product development that does not involve electron atm. If you can send over a PR, we can validate it works and accept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants