Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit fd9fbf6

Browse files
committed
fix: kubectl direct streaming fails to register a stream.on('error')
This PR also updates the uncaughtException handler so as not the exit. Fixes #6616
1 parent 3bc78a7 commit fd9fbf6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

packages/core/src/main/headless.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ setMedia(Media.Headless)
3939
let exitCode = 0
4040

4141
// electron pops up a window by default, for uncaught exceptions
42-
process.on('uncaughtException', async (err: Error) => {
43-
debug('uncaughtException')
44-
debug(err)
45-
const colors = await import('colors/safe')
46-
console.error(colors.red(err.toString()))
47-
process.exit(1)
42+
process.on('uncaughtException', (err: Error) => {
43+
console.error('Uncaught Exception', err)
4844
})
4945

5046
process.on('exit', code => {

plugins/plugin-kubectl/src/lib/util/fetch-file.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,18 @@ export async function openStream<T extends object>(
9494
})
9595

9696
stream.on('error', err => {
97-
debug('stream suddenly died', err)
98-
throw new Error(err)
97+
//
98+
// It's highly likely to be ok if the stream went away. This is
99+
// usually a sign that we are in the Kui proxy, and the Kui browser
100+
// client simply went away.
101+
//
102+
// !!DANGER!!: do not throw an exception here, as it will currently
103+
// percolate all the way up and result in a Kui proxy
104+
// failure due to an uncaughtException.
105+
//
106+
if (err.code !== 'ERR_STREAM_DESTROYED') {
107+
console.error('stream suddenly died', err)
108+
}
99109
})
100110

101111
JSONStream(stream, await onData, mgmt.onExit)

0 commit comments

Comments
 (0)