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

SyntaxError: Unexpected end of JSON input #14108

Closed
Ebrahim-Ramadan opened this issue Sep 23, 2024 · 1 comment
Closed

SyntaxError: Unexpected end of JSON input #14108

Ebrahim-Ramadan opened this issue Sep 23, 2024 · 1 comment
Labels
crash An issue that could cause a crash

Comments

@Ebrahim-Ramadan
Copy link

How can we reproduce the crash?

just did bun dev on a nextjs project, created this api endpoint at /api/google-callback/route.ts (as usual)
then hit this endpoint at http://localhost:3001/api/google-callback
then this stack trace showed up in the terminal
for any concern thats whats in the endpoint

import { revalidatePath } from "next/cache";
import { NextResponse } from "next/server";

export async function GET(req: Request) {
    const url = new URL(req.url);

    console.log('req', await req.json());
    revalidatePath('/')
        const redirectUrl = process.env.NODE_ENV === 'development'
        ? new URL('http://localhost:3001/')
        : new URL('/', url.origin); 

        return NextResponse.redirect(redirectUrl); 
}

Relevant log output

No response

Stack Trace (bun.report)

 ✓ Compiled /api/google-callback in 11.3s (66 modules)
 ⨯ 1 | (()=>{var e={"./dist/compiled/@edge-runtime/cookies/index.js":e=>{"use strict";var t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,a={};function s(e){var t;let r=["path"in e&&e.path&&`Path=${e.path}`,"expires"in e&&(e.expires||0===e.expires)&&`Expires=${("number"==typeof e.expires?new Date(e.expires):e.expires).toUTCString()}`,"maxAge"in e&&"number"==typeof e.maxAge&&`Max-Age=${e.maxAge}`,"domain"in e&&e.domain&&`Domain=${e.domain}`,"secure"in e&&e.secure&&"Secure","httpOnly"in e&&e.httpOnly&&"HttpOnly","sameSite"in e&&e.sameSite&&`SameSite=${e.sameSite}`,"partitioned"in e&&e.partitioned&&"Partitioned","priority"in e&&e.priority&&`Priority=${e.priority}`].filter(Boolean),n=`${e.name}=${encodeURIComponent(null!=(t=e.value)?t:"")}`;return 0===r.length?n:`${n}; ${r.join("; ")}`}function i(e){let t=new Map;for(let r of e.split(/; */)){if(!r)continue;let e=r.indexOf("=");if(-1===e){t.set(r,"true");continue}let[n,o]=[r.slice(0,e),r.slice(e+1)] | ... truncated 
2 |  * cookie
3 |  * Copyright(c) 2012-2014 Roman Shtylman
4 |  * Copyright(c) 2015 Douglas Christopher Wilson
5 |  * MIT Licensed
6 |  */t.parse=function(t,r){if("string"!=typeof t)throw TypeError("argument str must be a string");for(var o={},a=t.split(n),s=(r||{}).decode||e,i=0;i<a.length;i++){var c=a[i],l=c.indexOf("=");if(!(l<0)){var u=c.substr(0,l).trim(),d=c.substr(++l,c.length).trim();'"'==d[0]&&(d=d.slice(1,-1)),void 0==o[u]&&(o[u]=function(e,t){try{return t(e)}catch(t){return e}}(d,s))}}return o},t.serialize=function(e,t,n){var a=n||{},s=a.encode||r;if("function"!=typeof s)throw TypeError("option encode is invalid");if(!o.test(e))throw TypeError("argument name is invalid");var i=s(t);if(i&&!o.test(i))throw TypeError("argument val is invalid");var c=e+"="+i;if(null!=a.maxAge){var l=a.maxAge-0;if(isNaN(l)||!isFinite(l))throw TypeError("option maxAge is invalid");c+="; Max-Age="+Math.floor(l)}if(a.domain){if(!o.test(a.domain))throw TypeError("option domain is invalid");c+="; Domain="+a.domain}if(a.path){if(!o.test(a.path))throw TypeError("option path is invalid");c+="; Path="+a.path}if(a.expires){if("function"!=typeof a.expires.toUTCSt | ... truncated
 

SyntaxError: Unexpected end of JSON input
      at GET (10:20)
      at D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:55758
      at D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:48667
      at D:\f0\node_modules\next\dist\server\lib\trace\tracer.js:140:36
      at run (node:async_hooks:81:6)
      at wrap (D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:40953)
      at run (node:async_hooks:81:6)
      at wrap (D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:38292)
      at run (node:async_hooks:81:6)
      at D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:46552
      at execute (D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:46308)
      at D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:57017
      at handle (D:\f0\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:6:56994)
      at D:\f0\node_modules\next\dist\server\base-server.js:1359:60
      at doRender (D:\f0\node_modules\next\dist\server\base-server.js:1271:35)
      at D:\f0\node_modules\next\dist\server\base-server.js:1581:34
      at D:\f0\node_modules\next\dist\server\base-server.js:1489:77
      at get (D:\f0\node_modules\next\dist\server\response-cache\index.js:46:15)
      at D:\f0\node_modules\next\dist\server\base-server.js:1489:53
      at renderToResponseWithComponentsImpl (D:\f0\node_modules\next\dist\server\base-server.js:1026:48)
      at D:\f0\node_modules\next\dist\server\base-server.js:999:193
      at renderToResponseWithComponents (D:\f0\node_modules\next\dist\server\base-server.js:998:42)
      at D:\f0\node_modules\next\dist\server\base-server.js:1913:35

 GET /api/google-callback 500 in 12020ms
@Ebrahim-Ramadan Ebrahim-Ramadan added the crash An issue that could cause a crash label Sep 23, 2024
@Ebrahim-Ramadan
Copy link
Author

never mind, the problem was with the current nodejs version, had to reinstall it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash
Projects
None yet
Development

No branches or pull requests

1 participant