Skip to content

Commit

Permalink
Migrate from deprecated Deno APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydenseric committed Jan 19, 2025
1 parent 25cddb2 commit 8107e75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
`Deno.serve`.
- Migrated from the deprecated Deno standard library function
`readableStreamFromReader` to the new Deno API `Deno.FsFile.readable`.
- Migrated from the deprecated Deno APIs `Deno.FsFile.rid`, `Deno.resources`,
and `Deno.close` to manually calling the modern `Deno.FsFile` method
`Symbol.dispose`.

### Patch

Expand Down
6 changes: 3 additions & 3 deletions publicFileResponse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ export default async function publicFileResponse(

return new Response(file.readable, responseInit);
} catch (error) {
// Avoid closing an already closed file, see:
// https://github.com/denoland/deno/issues/14210
if (file.rid in Deno.resources()) Deno.close(file.rid);
// Safely ensure the file is closed, see:
// https://github.com/denoland/deno/issues/14210#issuecomment-2600381752
file[Symbol.dispose]();

throw error;
}
Expand Down

0 comments on commit 8107e75

Please sign in to comment.