Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not set pod as running when socket isn't connected #288

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ui/src/lib/store/podSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export interface PodSlice {
content: { data: { html: string; text: string; image: string } };
count: number;
}) => void;
setPodDisplayData: ({ id, content, count }) => void;
setPodExecuteReply: ({ id, result, count }) => void;
setPodStdout: ({ id, stdout }: { id: string; stdout: string }) => void;
setPodError: ({ id, ename, evalue, stacktrace }) => void;
setPodStream: ({ id, content }) => void;
setPodStatus: ({ id, status, lang }) => void;
clonePod: (id: string) => any;
}

Expand Down
30 changes: 11 additions & 19 deletions ui/src/lib/store/runtimeSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,16 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
});
return;
}
// Set this pod as running.
set({ runningId: id });
// Actually send the run request.
if (!get().socket) {
get().addError({
type: "error",
msg: "Runtime not connected",
});
return;
}
// Set this pod as running.
set({ runningId: id });
// Actually send the run request.
// Analyze code and set symbol table
get().parsePod(id);
// update anontations according to st
Expand Down Expand Up @@ -359,6 +359,13 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
* Add a pod to the chain and run it.
*/
wsRun: async (id) => {
if (!get().socket) {
get().addError({
type: "error",
msg: "Runtime not connected",
});
return;
}
// If this pod is a code pod, add it.
if (get().pods[id].type === "CODE") {
// Add to the chain
Expand Down Expand Up @@ -606,7 +613,7 @@ function wsConnect(set, get: () => MyState) {
};
}

function onMessage(set, get) {
function onMessage(set, get: () => MyState) {
return (msg) => {
// console.log("onMessage", msg.data || msg.body || undefined);
// msg.data for websocket
Expand Down Expand Up @@ -656,21 +663,6 @@ function onMessage(set, get) {
get().setPodStream({ id: podId, content });
}
break;
case "IO:execute_result":
{
let { podId, result, name } = payload;
get().setPodExecuteResult({ id: podId, result, name });
}
break;
case "IO:execute_reply":
// CAUTION ignore
break;
case "IO:error":
{
let { podId, name, ename, evalue, stacktrace } = payload;
get().setIOResult({ id: podId, name, ename, evalue, stacktrace });
}
break;
case "status":
{
const { lang, status, id } = payload;
Expand Down