Skip to content

Commit 7e153dc

Browse files
author
Marcos Alves
committed
fix: reject promise error cases in onReply (#279)
1 parent afa7272 commit 7e153dc

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

packages/react/src/components/cell/CellAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ export class CellAdapter {
485485
cellsStore.getState().setIsExecuting(this._id, false);
486486
return executeReplyMessage;
487487
} catch (e) {
488+
cellsStore.getState().setIsExecuting(this._id, false);
488489
// If we started executing, and the cell is still indicating this execution, clear the prompt.
489490
if (future && !cell.isDisposed && cell.outputArea.future === future) {
490491
cell.setPrompt('');
@@ -498,7 +499,6 @@ export class CellAdapter {
498499
model.setMetadata('execution', timingInfo);
499500
}
500501
}
501-
cellsStore.getState().setIsExecuting(this._id, false);
502502
throw e;
503503
}
504504
}

packages/react/src/examples/CellExecuteControl.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ const btnStyle = {
2222
marginTop: '20px'
2323
}
2424

25-
const CELL_CODE = `
26-
import time
27-
time.sleep(10)
28-
`
25+
const CELL_CODE = `import time\ntime.sleep(3)`
2926

3027
const CellExecuteControl = () => {
3128
const [executionDisable, setExecutionDisable] = React.useState(false);
@@ -50,13 +47,13 @@ const CellExecuteControl = () => {
5047
<Box style={{marginTop: '20px'}}>
5148
<Cell
5249
id='1'
53-
type={'code'}
50+
type='code'
5451
source={CELL_CODE}
5552
autoStart={false}
5653
showToolbar={false} />
5754
<Cell
5855
id='2'
59-
type={'code'}
56+
type='code'
6057
autoStart={false}
6158
showToolbar={false} />
6259
<Button

packages/react/src/jupyter/kernel/KernelExecutor.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,13 @@ export class KernelExecutor {
258258
break;
259259
case 'error':
260260
{
261-
const { ename, evalue, traceback } = (
262-
content as any as KernelMessage.IErrorMsg
263-
).content;
261+
// NOTE: This block that was here previously cannot extract the properties consistently,
262+
//causing the Promise to never be rejected in case of an execution error.
263+
// const { ename, evalue, traceback } = (
264+
// content as any as KernelMessage.IErrorMsg
265+
// ).content;
264266
this._executed.reject(
265-
`${ename}: ${evalue}\n${(traceback ?? []).join('\n')}`
267+
`${content.ename}: ${content.evalue}\n${(content.traceback ?? []).join('\n')}`
266268
);
267269
}
268270
break;

0 commit comments

Comments
 (0)