mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* fix: recover network requests after Network Service restart * chore: reuse implementation * chore: make linter happy * chore: fix lint --------- Co-authored-by: deepak1556 <hop2deep@gmail.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
25 lines
547 B
JavaScript
25 lines
547 B
JavaScript
const { net } = require('electron');
|
|
|
|
process.parentPort.on('message', async (e) => {
|
|
const { type, url } = e.data;
|
|
|
|
if (type === 'fetch') {
|
|
try {
|
|
const response = await net.fetch(url);
|
|
const body = await response.text();
|
|
process.parentPort.postMessage({
|
|
ok: response.ok,
|
|
status: response.status,
|
|
body
|
|
});
|
|
} catch (error) {
|
|
process.parentPort.postMessage({
|
|
ok: false,
|
|
error: error.message
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
process.parentPort.postMessage({ type: 'ready' });
|