Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed compression for node runtime since its buffering the response during streaming #309

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/handlers/handlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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 @@ -946,6 +947,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
Loading