File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,23 @@ export class OpenFile extends Fd {
6161 return wasi . ERRNO_SUCCESS ;
6262 }
6363
64+ fd_close ( ) : number {
65+ // convert file.data back to a non-resizable arraybuffer after
66+ // closing, otherwise using it in web api (e.g. creating a
67+ // Response object) could throw. see:
68+ //
69+ // https://webidl.spec.whatwg.org/#AllowResizable
70+ // https://issues.chromium.org/issues/40249433
71+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1842773
72+ if (
73+ this . file . data . buffer instanceof ArrayBuffer &&
74+ this . file . data . buffer . resizable
75+ ) {
76+ this . file . data = new Uint8Array ( this . file . data ) ;
77+ }
78+ return wasi . ERRNO_SUCCESS ;
79+ }
80+
6481 fd_fdstat_get ( ) : { ret : number ; fdstat : wasi . Fdstat | null } {
6582 return { ret : 0 , fdstat : new wasi . Fdstat ( wasi . FILETYPE_REGULAR_FILE , 0 ) } ;
6683 }
You can’t perform that action at this time.
0 commit comments