cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

"Unexpected token p in JSON at position 4" on startup

Open kolaente opened this issue 2 years ago • 13 comments

Issue Summary

Running the latest (3.2.10) release with docker yields the following error message in the console:

calcom_1    | @calcom/web:start: [next-auth][error][CLIENT_FETCH_ERROR]
calcom_1    | @calcom/web:start: https://next-auth.js.org/errors#client_fetch_error Unexpected token p in JSON at position 4 {
calcom_1    | @calcom/web:start:   error: {
calcom_1    | @calcom/web:start:     message: 'Unexpected token p in JSON at position 4',
calcom_1    | @calcom/web:start:     stack: 'SyntaxError: Unexpected token p in JSON at position 4\n' +
calcom_1    | @calcom/web:start:       '    at JSON.parse (<anonymous>)\n' +
calcom_1    | @calcom/web:start:       '    at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)\n' +
calcom_1    | @calcom/web:start:       '    at successSteps (node:internal/deps/undici/undici:6636:27)\n' +
calcom_1    | @calcom/web:start:       '    at node:internal/deps/undici/undici:1236:60\n' +
calcom_1    | @calcom/web:start:       '    at node:internal/process/task_queues:140:7\n' +
calcom_1    | @calcom/web:start:       '    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)\n' +
calcom_1    | @calcom/web:start:       '    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)\n' +
calcom_1    | @calcom/web:start:       '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
calcom_1    | @calcom/web:start:     name: 'SyntaxError'
calcom_1    | @calcom/web:start:   },
calcom_1    | @calcom/web:start:   url: 'https://cal.example.com/api/auth/csrf',
calcom_1    | @calcom/web:start:   message: 'Unexpected token p in JSON at position 4'
calcom_1    | @calcom/web:start: }

Everything seems to still work as expected but the error looks like it should not happen.

Steps to Reproduce

  1. Upgrade to 3.2.10 using docker

kolaente avatar Sep 13 '23 08:09 kolaente

Is the clinet loading at all? @kolaente

shawshankkumar avatar Sep 13 '23 10:09 shawshankkumar

How do I check that?

kolaente avatar Sep 13 '23 10:09 kolaente

Hey @kolaente I'm unable to re-create it 🤔 Are you still facing this issue in our latest release >= v3.3.6?

alishaz-polymath avatar Oct 09 '23 05:10 alishaz-polymath

@alishaz-polymath Can't check because the docker image is not yet published:

$ docker compose pull
[+] Pulling 2/2
 ✘ calcom Error                                                                                                                                                                                                                                                                                                           1.5s
 ✔ database Pulled                                                                                                                                                                                                                                                                                                        1.2s
Error response from daemon: manifest for calcom/cal.com:v3.3.6 not found: manifest unknown: manifest unknown

kolaente avatar Oct 09 '23 09:10 kolaente

@alishaz-polymath Can't check because the docker image is not yet published:

$ docker compose pull
[+] Pulling 2/2
 ✘ calcom Error                                                                                                                                                                                                                                                                                                           1.5s
 ✔ database Pulled                                                                                                                                                                                                                                                                                                        1.2s
Error response from daemon: manifest for calcom/cal.com:v3.3.6 not found: manifest unknown: manifest unknown

Can you try 3.3.4 instead?

alishaz-polymath avatar Oct 09 '23 09:10 alishaz-polymath

That doesn't exist either

kolaente avatar Oct 09 '23 09:10 kolaente

Interesting. Let me take a look 🙏

alishaz-polymath avatar Oct 09 '23 10:10 alishaz-polymath

UPDATE We're facing certain issues with the release in docker, and it is under investigation. I'll confirm here when that is sorted 🙏

alishaz-polymath avatar Oct 13 '23 09:10 alishaz-polymath

Hey @kolaente can you test now?

alishaz-polymath avatar Oct 15 '23 18:10 alishaz-polymath

Was able to test with 3.3.7, same error still happening:

calcom-calcom-1  | @calcom/web:start: [next-auth][error][CLIENT_FETCH_ERROR]
calcom-calcom-1  | @calcom/web:start: https://next-auth.js.org/errors#client_fetch_error Unexpected token p in JSON at position 4 {
calcom-calcom-1  | @calcom/web:start:   error: {
calcom-calcom-1  | @calcom/web:start:     message: 'Unexpected token p in JSON at position 4',
calcom-calcom-1  | @calcom/web:start:     stack: 'SyntaxError: Unexpected token p in JSON at position 4\n' +
calcom-calcom-1  | @calcom/web:start:       '    at JSON.parse (<anonymous>)\n' +
calcom-calcom-1  | @calcom/web:start:       '    at parseJSONFromBytes (node:internal/deps/undici/undici:6662:19)\n' +
calcom-calcom-1  | @calcom/web:start:       '    at successSteps (node:internal/deps/undici/undici:6636:27)\n' +
calcom-calcom-1  | @calcom/web:start:       '    at node:internal/deps/undici/undici:1236:60\n' +
calcom-calcom-1  | @calcom/web:start:       '    at node:internal/process/task_queues:140:7\n' +
calcom-calcom-1  | @calcom/web:start:       '    at AsyncResource.runInAsyncScope (node:async_hooks:203:9)\n' +
calcom-calcom-1  | @calcom/web:start:       '    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)\n' +
calcom-calcom-1  | @calcom/web:start:       '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
calcom-calcom-1  | @calcom/web:start:     name: 'SyntaxError'
calcom-calcom-1  | @calcom/web:start:   },
calcom-calcom-1  | @calcom/web:start:   url: 'https://cal.kolaente.de/api/auth/csrf',
calcom-calcom-1  | @calcom/web:start:   message: 'Unexpected token p in JSON at position 4'
calcom-calcom-1  | @calcom/web:start: }
calcom-calcom-1  | @calcom/web:start: react-i18next:: You will need to pass in an i18next instance by using initReactI18next
calcom-calcom-1  | @calcom/web:start: 16:02:51.758 WARN RateLimit Disabled due to not finding UPSTASH env variables
calcom-calcom-1  | @calcom/web:start: [PERF]: getByViewer(1) took 28.900772094726562ms

kolaente avatar Oct 17 '23 16:10 kolaente

No docker image for 3.4.1 available, but 3.4.0 exists. Still the same error though.

kolaente avatar Oct 18 '23 15:10 kolaente

I had the same issue, and it was my env var ALLOWED_HOSTNAMES that was not a valid JSON. I update it with : ALLOWED_HOSTNAMES=["https://cal.domain.com"] and this error is gone, on my side.

lionep avatar Dec 08 '23 09:12 lionep

Same here and solution/this comment from @lionep helped.

kortom23 avatar Jan 17 '24 11:01 kortom23

I had the same issue, and it was my env var ALLOWED_HOSTNAMES that was not a valid JSON. I update it with : ALLOWED_HOSTNAMES=["https://cal.domain.com"] and this error is gone, on my side.

This seems to have solved it for everybody 🙏 Thank you @lionep 🙌 🚀

alishaz-polymath avatar Feb 06 '24 09:02 alishaz-polymath

using ALLOWED_HOSTNAMES=["https://cal.domain.com"] did not work for me, i'm running coolify and if I used that i got "Unexpected token p in JSON at position 2" and application wouldnt run

marcoantonio123456 avatar Jun 25 '24 15:06 marcoantonio123456

Maybe coolify is escaping some chars in environment ? Can you try do enter your container (if any?) and print the output of :

env | grep  ALLOWED_HOSTNAMES

lionep avatar Jun 25 '24 15:06 lionep