-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Do not throw an error when killing the verdaccio process #7695
Merged
mattsoulanille
merged 4 commits into
tensorflow:master
from
mattsoulanille:fix_verdaccio_disconnect_on_kill
May 24, 2023
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a22d73c
Do not throw an error when killing the verdaccio process
mattsoulanille 761ef92
Merge branch 'master' into fix_verdaccio_disconnect_on_kill
mattsoulanille 72d1c65
Fix nit
mattsoulanille 0f6fd99
Merge branch 'master' into fix_verdaccio_disconnect_on_kill
mattsoulanille File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ import * as readline from 'readline'; | |
import * as shell from 'shelljs'; | ||
import rimraf from 'rimraf'; | ||
import * as path from 'path'; | ||
import {ChildProcess, fork} from 'child_process'; | ||
import {fork} from 'child_process'; | ||
|
||
export interface Phase { | ||
// The list of packages that will be updated with this change. | ||
|
@@ -615,7 +615,7 @@ export function memoize<I, O>(f: (arg: I) => Promise<O>): (arg: I) => Promise<O> | |
} | ||
} | ||
|
||
export async function runVerdaccio(): Promise<ChildProcess> { | ||
export async function runVerdaccio(): Promise<() => void> { | ||
// Remove the verdaccio package store. | ||
// TODO(mattsoulanille): Move the verdaccio storage and config file here | ||
// once the nightly verdaccio tests are handled by this script. | ||
|
@@ -625,7 +625,8 @@ export async function runVerdaccio(): Promise<ChildProcess> { | |
// messaging works and verdaccio can tell node that it has started. | ||
// https://verdaccio.org/docs/verdaccio-programmatically/#using-fork-from-child_process-module | ||
const verdaccioBin = require.resolve('verdaccio/bin/verdaccio'); | ||
const serverProcess = fork(verdaccioBin, ['--config=e2e/scripts/verdaccio.yaml']); | ||
const config = path.join(__dirname, '../e2e/scripts/verdaccio.yaml'); | ||
const serverProcess = fork(verdaccioBin, [`--config=${config}`]); | ||
const ready = new Promise<void>((resolve, reject) => { | ||
const timeLimitMilliseconds = 30_000; | ||
console.log(`Waiting ${timeLimitMilliseconds / 1000} seconds for ` + | ||
|
@@ -647,15 +648,22 @@ export async function runVerdaccio(): Promise<ChildProcess> { | |
serverProcess.on('error', (err: unknown) => { | ||
throw new Error(`Verdaccio error: ${err}`); | ||
}); | ||
serverProcess.on('disconnect', (err: unknown) => { | ||
throw new Error(`Verdaccio disconnected: ${err}`); | ||
}); | ||
|
||
const onUnexpectedDisconnect = (err: unknown) => { | ||
throw new Error(`Verdaccio process unexpectedly disconnected: ${err}`); | ||
}; | ||
serverProcess.on('disconnect', onUnexpectedDisconnect); | ||
|
||
const killVerdaccio = () => { | ||
serverProcess.off('disconnect', onUnexpectedDisconnect); | ||
serverProcess.kill(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
|
||
// Kill verdaccio when node exits. | ||
process.on('exit', () => {serverProcess.kill();}); | ||
process.on('exit', killVerdaccio); | ||
|
||
await ready; | ||
return serverProcess; | ||
return killVerdaccio; | ||
} | ||
|
||
/** | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More reliable config directory resolution.