Skip to content

Commit

Permalink
throw
Browse files Browse the repository at this point in the history
  • Loading branch information
pwang347 committed Dec 2, 2024
1 parent 03d7858 commit 9cc91ed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/standalone/api/kernels/kernel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,12 +432,15 @@ class WrappedKernelPerExtension extends DisposableBase implements Kernel {
);

try {
let hasAccess: boolean = false;
for await (const output of kernelExecution.executeCode(code, this.extensionId, events, token, async () => {
try {
// Validate access before execution
await this.checkAccess();
hasAccess = true;
return true;
} catch (e) {
hasAccess = false;
return false;
}
})) {
Expand All @@ -458,6 +461,9 @@ class WrappedKernelPerExtension extends DisposableBase implements Kernel {
yield output;
}
}
if (!hasAccess) {
throw new KernelAPIAccessRevoked();
}
} finally {
dispose(disposables);
}
Expand Down

0 comments on commit 9cc91ed

Please sign in to comment.