question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Requests are immediately canceled when ran in Electron

See original GitHub issue

Hello,

Axios cancels all subsequent requests after calling the initial requests during ComponentWillMount() phase of the ReactJS life cycle.

Afterwards, the requests are immediately canceled. Doesn’t matter what phase of the ReactJS lifecycle they are called.

This only occurs when running on Electron. This problem does not persist on browser. I suspect the issue is caused by this:

    if (typeof XMLHttpRequest !== 'undefined') {
         // For browsers use XHR adapter
     axios.defaults.adapter = xhrAdapter
 } else if (typeof process !== 'undefined') {
     // For node use HTTP adapter
     axios.defaults.adapter = httpAdapter;
}

As the browser is correctly using the xhrAdapter and Electron is not using the httpAdapter. I came across a similar issue that was closed, and after following the solution, I was able to get the request to send for approx. <15 seconds before the requests started to immediately cancel again.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
heidemncommented, Nov 18, 2019

Also got trouble using Axios 0.19.0 in Electron 6.1.4 + Node 10.16.3.

I didn’t investigate it fully, but around 30-50% of the requests got “lost” and never returned a response.

This fixed it for me (in the frontend/Vue.js code of the Electron app):

const axios = require('axios');
axios.defaults.adapter = require('axios/lib/adapters/xhr');
0reactions
github-actions[bot]commented, Mar 1, 2021

Hello! 👋

This issue is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the issue will be closed in a few days.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Electron application exits immediately after starting
Electron 5 was installed in the local node_modules. I was able to develop and run the application from VSCode. I ran 'ncu' and...
Read more >
app | Electron
If callback is called without a username or password, the authentication request will be cancelled and the authentication error will be returned to...
Read more >
All of the Documentation | Electron - GitHub Pages
However, the request remains active until either the application becomes active or the request is canceled. Returns Integer an ID representing the request....
Read more >
The Ultimate Guide to Electron with React | by Aditya Patnaik
Let's quickly set up a react app with Electron. It is assumed that you have node and npm installed. Create a folder named...
Read more >
7.5: Electron Affinities - Chemistry LibreTexts
The electron affinity (EA) of an element is the energy change that ... than those of the elements immediately below them in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found