Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
saltyshiomix committed Nov 9, 2024
2 parents 94eb714 + ef8063e commit c07a31f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/nextron-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import webpack from 'webpack'
import * as logger from './logger'
import { getNextronConfig } from './configs/getNextronConfig'
import { config } from './configs/webpack.config.development'
import { waitForPort } from 'get-port-please'
import type { ChildProcess } from 'child_process'

const args = arg({
Expand Down Expand Up @@ -42,7 +43,8 @@ if (args['--inspect']) {
const nextronConfig = getNextronConfig()

const rendererPort = args['--renderer-port'] || 8888
const startupDelay = nextronConfig.startupDelay || args['--startup-delay'] || 0
const startupDelay =
nextronConfig.startupDelay || args['--startup-delay'] || 10_000

let electronOptions = args['--electron-options'] || ''
if (!electronOptions.includes('--remote-debugging-port')) {
Expand Down Expand Up @@ -115,9 +117,16 @@ const execaOptions: execa.Options = {
rendererProcess = startRendererProcess()

// wait until renderer process is ready
await new Promise<void>((resolve) =>
setTimeout(() => resolve(), startupDelay)
)
await waitForPort(rendererPort, {
delay: 500,
retries: startupDelay / 500,
}).catch(() => {
logger.error(
`Failed to start renderer process with port ${rendererPort} in ${startupDelay}ms`
)
killWholeProcess()
process.exit(1)
})

// wait until main process is ready
await new Promise<void>((resolve) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"chalk": "4.1.2",
"execa": "5.1.1",
"fs-extra": "11.2.0",
"get-port-please": "^3.1.2",
"terser-webpack-plugin": "5.3.10",
"tsconfig-paths-webpack-plugin": "4.1.0",
"webpack": "5.92.0",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c07a31f

Please sign in to comment.