[twenty-server] no-misused-promise lint (#20529)
# Introduction
Adding `no-miused-promise` lint rule to the twenty-server
In order to flag such pattern
```ts
// ❌ Flagged — forEach doesn't await the callback
items.forEach(async (item) => {
await process(item);
});
```
## What happened
- Refactored the code-interpreter driver to have a async onResult (
which is also expected by e2b )
- Workspace manager still dirty solution including force cast
- Basic fixes
This commit is contained in:
+3
-3
@@ -96,7 +96,7 @@ export class E2BDriver implements CodeInterpreterDriver {
|
||||
const execution = await sbx.runCode(envSetup + code, {
|
||||
onStdout: (data) => callbacks?.onStdout?.(data.line),
|
||||
onStderr: (data) => callbacks?.onStderr?.(data.line),
|
||||
onResult: (result) => {
|
||||
onResult: async (result) => {
|
||||
if (result.png) {
|
||||
const outputFile: OutputFile = {
|
||||
filename: `chart-${chartCounter++}.png`,
|
||||
@@ -105,7 +105,7 @@ export class E2BDriver implements CodeInterpreterDriver {
|
||||
};
|
||||
|
||||
outputFiles.push(outputFile);
|
||||
callbacks?.onResult?.(outputFile);
|
||||
await callbacks?.onResult?.(outputFile);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -126,7 +126,7 @@ export class E2BDriver implements CodeInterpreterDriver {
|
||||
};
|
||||
|
||||
outputFiles.push(outputFile);
|
||||
callbacks?.onResult?.(outputFile);
|
||||
await callbacks?.onResult?.(outputFile);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ export type ExecutionContext = {
|
||||
export type StreamCallbacks = {
|
||||
onStdout?: (line: string) => void;
|
||||
onStderr?: (line: string) => void;
|
||||
onResult?: (result: OutputFile) => void;
|
||||
onResult?: (result: OutputFile) => Promise<void>;
|
||||
};
|
||||
|
||||
export interface CodeInterpreterDriver {
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ export class LocalDriver implements CodeInterpreterDriver {
|
||||
};
|
||||
|
||||
outputFiles.push(outputFile);
|
||||
callbacks?.onResult?.(outputFile);
|
||||
await callbacks?.onResult?.(outputFile);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user