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.

Immediate listening for connections

See original GitHub issue

Description

I’m using Vite with Electron, and my npm run dev command runs vite and electron . at the same time. Electron tries to connect to the Vite dev server before it’s ready, and gets an ERR_CONNECTION_REFUSED.

Suggested solution

It would be great if Vite could immediately start listening to requests and respond once it’s ready to

Alternative

No response

Additional context

No response

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sapphi-redcommented, Aug 29, 2022

This is not possible. Vite needs to load/resolve config before server start.

Also this does not solve your problem. Even if the dev server listens as quickly as possbile, it is not guaranteed to be started before electron accesses.

FYI you could use a plugin like this to do something after the dev server started to listen to a port.

const p = {
  name: '',
  configureServer(server){
    server.httpServer.once('listening', ()=>{
        // here
    })
  }
}
0reactions
probablykaspercommented, Aug 29, 2022

By the way, thank you so much for suggesting to make a plugin! Works great:

const plugin = {
  name: 'electron-start',
  configureServer(server) {
    server.httpServer?.once('listening', () => {
      console.log('\nStarting Electron...')
      const child = exec('NODE_ENV=development electron .')
      child.stdout?.pipe(process.stdout)
      child.stderr?.pipe(process.stderr)
    })
  },
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Practice Active Listening: 16 Examples & Techniques
Active listening is a listening technique useful in building therapeutic relationships and creating empathy.
Read more >
How “Good Listening” Helps You Connect with the World
Good Listening Will Strengthen Your Relationships​​ Those who listen to understand have greater satisfaction in their interpersonal relationships than others. ...
Read more >
How to Listen and Build Deeper Connections with People
1. Practice active listening. · 2. Connect on an emotional level. · 3. Focus on the other person with questions. · 4. Pay...
Read more >
10 Ways to Immediately Improve Your Listening (and ...
Focus on what they're saying. Don't allow other thoughts or sounds to sway your concentration. 2. Listen to the content of their speech....
Read more >
11 Active Listening Skills To Practice (With Examples) - Indeed
Build connections · Develop trust · Identify and solve problems · Increase your understanding of various topics · Avoid missing critical information.
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