Skip to content

Commit

Permalink
default null body to empty stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mistval committed Aug 17, 2024
1 parent 385b756 commit dd50ad6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Request as NodeFetchRequestType } from 'node-fetch';
import { Readable } from 'stream';
import { FormData } from 'formdata-node';
import { getNFCResponseClass as getNFCResponseClass } from './classes/response.js';
import { MemoryCache } from './classes/caching/memory_cache.js';
Expand Down Expand Up @@ -94,15 +95,15 @@ async function getResponse(
if (shouldCache) {
const cacheSetResult = await fetchCustomization.cache.set(
cacheKey,
bodyStream!,
bodyStream ?? Readable.from(Buffer.alloc(0)),
serializedMeta,
);

bodyStream = cacheSetResult.bodyStream;
}

return new NFCResponse(
bodyStream!,
bodyStream ?? Readable.from(Buffer.alloc(0)),
serializedMeta,
ejectSelfFromCache,
false,
Expand Down

0 comments on commit dd50ad6

Please sign in to comment.