Skip to content

Commit

Permalink
Use the global web type
Browse files Browse the repository at this point in the history
  • Loading branch information
Schniz committed Feb 14, 2022
1 parent ab61023 commit 04177b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions packages/next/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { ParsedNextUrl } from '../shared/lib/router/utils/parse-next-url'
import type { PrerenderManifest } from '../build'
import type { Rewrite } from '../lib/load-custom-routes'
import type { BaseNextRequest, BaseNextResponse } from './base-http'
import type { ReadableStream } from 'next/dist/compiled/web-streams-polyfill/ponyfill'
import type { ReadableStream as ReadableStreamPolyfill } from 'next/dist/compiled/web-streams-polyfill/ponyfill'
import { TransformStream } from 'next/dist/compiled/web-streams-polyfill/ponyfill'

import { execOnce } from '../shared/lib/utils'
Expand Down Expand Up @@ -1273,7 +1273,7 @@ export default class NextNodeServer extends BaseServer {
},
url: url,
page: page,
body: currentBody,
body: currentBody as unknown as ReadableStream<Uint8Array>,
},
useCache: !this.nextConfig.experimental.runtime,
onWarning: (warning: Error) => {
Expand Down Expand Up @@ -1352,7 +1352,7 @@ export default class NextNodeServer extends BaseServer {
*/
function requestToBodyStream(
request: IncomingMessage
): ReadableStream<Uint8Array> {
): ReadableStreamPolyfill<Uint8Array> {
const transform = new TransformStream<Uint8Array, Uint8Array>({
start(controller) {
request.on('data', (chunk) => controller.enqueue(chunk))
Expand All @@ -1368,8 +1368,8 @@ function requestToBodyStream(
* A simple utility to take an original stream and have
* an API to duplicate it without closing it or mutate any variables
*/
function teeableStream<T>(originalStream: ReadableStream<T>): {
duplicate(): ReadableStream<T>
function teeableStream<T>(originalStream: ReadableStreamPolyfill<T>): {
duplicate(): ReadableStreamPolyfill<T>
} {
return {
duplicate() {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/web/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function adapter(params: {
page: params.page,
input: params.request.url,
init: {
body: params.request.body as unknown as ReadableStream<Uint8Array>,
body: params.request.body,
geo: params.request.geo,
headers: fromNodeHeaders(params.request.headers),
ip: params.request.ip,
Expand Down
1 change: 0 additions & 1 deletion packages/next/server/web/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { I18NConfig } from '../config-shared'
import type { ReadableStream } from 'next/dist/compiled/web-streams-polyfill/ponyfill'
import type { NextRequest } from '../web/spec-extension/request'
import type { NextFetchEvent } from '../web/spec-extension/fetch-event'
import type { NextResponse } from './spec-extension/response'
Expand Down

0 comments on commit 04177b8

Please sign in to comment.