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

Request clone method does not clone the body in bun #285

Open
Kuechlin opened this issue Jun 28, 2024 · 0 comments
Open

Request clone method does not clone the body in bun #285

Kuechlin opened this issue Jun 28, 2024 · 0 comments

Comments

@Kuechlin
Copy link

Kuechlin commented Jun 28, 2024

Describe the bug

The request body is empty in Strategy.authenticate() when using bun as runtime.

In src/authenticator.ts a new Request is created but the body is not cloned in bun.

  new Request(request.url, request),

It is a know bug in bun issue, but is not getting fixed soon.

A option to disable cloning the request would fix the issue for me.

Your Example Website or App

none

Steps to Reproduce the Bug or Issue

use bun

Expected behavior

A option to disable cloning the request

Screenshots or Videos

No response

Platform

  • OS: [Linux]
  • Browser: [Firefox]
  • Version: [^3.7.0]

Additional context

to fix the issue for me i have to override the authenticate method without cloning the request

function authenticate(
  this: any,
  strategy: string,
  request: Request,
  options: Pick<
    AuthenticateOptions,
    "successRedirect" | "failureRedirect" | "throwOnError" | "context"
  > = {}
): Promise<User> {
  const strategyObj = this.strategies.get(strategy);
  if (!strategyObj) throw new Error(`Strategy ${strategy} not found.`);
  return strategyObj.authenticate(request, this.sessionStorage, {
    throwOnError: this.throwOnError,
    ...options,
    name: strategy,
    sessionKey: this.sessionKey,
    sessionErrorKey: this.sessionErrorKey,
    sessionStrategyKey: this.sessionStrategyKey,
  });
}

// @ts-expect-error
authenticator.authenticate = authenticate.bind(authenticator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant