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

"Unexpected end of JSON input" error due to unimplemented response.clone in bun. #66

Open
coji opened this issue Sep 19, 2023 · 0 comments

Comments

@coji
Copy link

coji commented Sep 19, 2023

I implemented Google login using remix-auth-oauth2 and remix-auth-google, based on remix-on-bun by @sergiodxa . However, I encountered an "Unexpected end of JSON input" error when calling authenticator.authenticate in the callback.

Upon investigation, I found that the issue is due to the lack of Response.clone implementation in Bun. This causes an error in response.json() when getAccessToken tries to read from a cloned response created in fetchAccessToken.

While waiting for Bun to implement this might be an option, it seems unnecessary to clone the response in fetchAccessToken in the first place.

I've managed to get it working by applying the following patch on my end. Is cloning really necessary?

diff --git a/node_modules/remix-auth-oauth2/build/index.js b/node_modules/remix-auth-oauth2/build/index.js
index 78f2712..1597705 100644
--- a/node_modules/remix-auth-oauth2/build/index.js
+++ b/node_modules/remix-auth-oauth2/build/index.js
@@ -251,7 +251,7 @@ class OAuth2Strategy extends remix_auth_1.Strategy {
             let body = await response.text();
             throw body;
         }
-        return await this.getAccessToken(response.clone());
+        return await this.getAccessToken(response);
     }
 }
 exports.OAuth2Strategy = OAuth2Strategy;
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