Skip to content

Commit

Permalink
Merge pull request #309 from mohankumarelec/main
Browse files Browse the repository at this point in the history
Removed compression for node runtime since its buffering the response during streaming
  • Loading branch information
VisargD authored Jul 25, 2024
2 parents ba7677e + 34df0b7 commit 0261777
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/handlers/handlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
import { env } from 'hono/adapter';
import { OpenAIChatCompleteJSONToStreamResponseTransform } from '../providers/openai/chatComplete';
import { OpenAICompleteJSONToStreamResponseTransform } from '../providers/openai/complete';
import { getRuntimeKey } from 'hono/adapter';

/**
* Constructs the request options for the API call.
Expand Down Expand Up @@ -970,6 +971,9 @@ export function updateResponseHeaders(
// Brotli compression causes errors at runtime, removing the header in that case
response.headers.delete('content-encoding');
}
if (getRuntimeKey() == 'node') {
response.headers.delete('content-encoding');
}

// Delete content-length header to avoid conflicts with hono compress middleware
// workerd environment handles this authomatically
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const app = new Hono();

app.use('*', (c, next) => {
const runtime = getRuntimeKey();
if (runtime !== 'lagon' && runtime !== 'workerd') {
if (runtime !== 'lagon' && runtime !== 'workerd' && runtime !== 'node') {
return compress()(c, next);
}
return next();
Expand Down

0 comments on commit 0261777

Please sign in to comment.