Skip to content

Commit 594b25f

Browse files
committed
handle Node 18 more gracefully
1 parent f5b1aa1 commit 594b25f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

shared/api-utils.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ export async function respondWithDataTable(data: URLSearchParams | FormData) {
55
const headerCellStyle = `${cellStyle} border-bottom-width: 2px;`
66

77
async function stringifyValue(value: string | File) {
8-
if (value instanceof File) {
8+
// this would be value instanceof File except the global File was not added until Node 20.
9+
// feel free to update this when we drop Node 18 support after April 2025.
10+
if (
11+
typeof value === 'object' &&
12+
'size' in value &&
13+
'arrayBuffer' in value &&
14+
'type' in value &&
15+
'name' in value
16+
) {
917
if (value.size > MAX_FILE_SIZE) {
1018
throw new Response(`File larger than ${MAX_FILE_SIZE} bytes`, {
1119
status: 400,

0 commit comments

Comments
 (0)