Skip to content

Commit

Permalink
Fix the Wasm worker to initialize the app directories (#6887)
Browse files Browse the repository at this point in the history
* Fix the Wasm worker to initialize the app directories

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
whitphx and gradio-pr-bot authored Dec 27, 2023
1 parent 31c2316 commit 8333db8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/tender-parks-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/wasm": patch
"gradio": patch
---

feat:Fix the Wasm worker to initialize the app directories
9 changes: 9 additions & 0 deletions js/wasm/src/webworker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ async function initializeApp(
options: InMessageInitApp["data"],
updateProgress: (log: string) => void
): Promise<void> {
const appHomeDir = getAppHomeDir(appId);
console.debug("Creating a home directory for the app.", {
appId,
appHomeDir
});
pyodide.FS.mkdir(appHomeDir);

console.debug("Mounting files.", options.files);
updateProgress("Mounting files");
await Promise.all(
Expand Down Expand Up @@ -249,6 +256,8 @@ function setupMessageHandler(receiver: MessageTransceiver): void {
// This multi-app mechanism was introduced for a SharedWorker, but the same mechanism is used for a DedicatedWorker as well.
const appId = generateRandomString(8);

console.debug("Set up a new app.", { appId });

const updateProgress = (log: string): void => {
const message: OutMessage = {
type: "progress-update",
Expand Down

0 comments on commit 8333db8

Please sign in to comment.