Skip to content

Commit

Permalink
Merge pull request #2706 from posit-dev/fix-startup-failure-error-mes…
Browse files Browse the repository at this point in the history
…sage

Fix React error when Jupyter socket times out and increase socket connection timeouts
  • Loading branch information
petetronic authored Apr 10, 2024
2 parents 8cad708 + 7f0e7c8 commit c5d799f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions extensions/jupyter-adapter/src/JupyterKernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,12 +344,12 @@ export class JupyterKernel extends EventEmitter implements vscode.Disposable {
this.log(`Connecting to kernel sockets defined in ${session.state.connectionFile}...`);

// Wait for the sockets to connect or the timeout to expire. Note that
// each socket has 10 second timeout for connecting, so this is just an
// each socket has 20 second timeout for connecting, so this is just an
// additional safeguard.
await withTimeout(
this.connect(session.state.connectionFile),
15000,
`Timed out waiting 15 seconds for kernel to connect to sockets`);
25000,
`Timed out waiting 25 seconds for kernel to connect to sockets`);

// We're connected! Establish the socket listeners
return this.establishSocketListeners();
Expand Down Expand Up @@ -1577,11 +1577,11 @@ export class JupyterKernel extends EventEmitter implements vscode.Disposable {
* Creates a detailed error object to emit to the client when the kernel fails
* to start.
*
* @param message The error message
* @param error The source error message or object
* @returns A StartupFailure object containing the error message and the
* contents of the kernel's log file, if it exists
*/
private createStartupFailure(message: string): StartupFailure {
private createStartupFailure(err: any): StartupFailure {
// Read the content of the log file, if it exists; this may contain more detail
// about why the kernel exited.
let logFileContent = '';
Expand All @@ -1599,6 +1599,6 @@ export class JupyterKernel extends EventEmitter implements vscode.Disposable {
.join('\n');

// Create a startup failure message
return new StartupFailure(message, logFileContent);
return new StartupFailure(err.toString(), logFileContent);
}
}
8 changes: 4 additions & 4 deletions extensions/jupyter-adapter/src/JupyterSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ export class JupyterSocket implements vscode.Disposable {
}
// Compute how long we've been waiting
const waitTime = Date.now() - startTime;
if (waitTime >= 10000) {
// If we've been waiting for more than 10 seconds, reject the promise
this._logger(`${this._title} socket connect timed out after 10 seconds`);
this._connectPromise.reject(new Error('Socket connect timed out after 10 seconds'));
if (waitTime >= 20000) {
// If we've been waiting for more than 20 seconds, reject the promise
this._logger(`${this._title} socket connect timed out after 20 seconds`);
this._connectPromise.reject(new Error('Socket connect timed out after 20 seconds'));
this._connectPromise = undefined;

// Return to the uninitialized state so a new connection can be attempted if
Expand Down

0 comments on commit c5d799f

Please sign in to comment.