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

Error on Deno1.30.1 #5

Open
f1w3 opened this issue Feb 3, 2023 · 3 comments
Open

Error on Deno1.30.1 #5

f1w3 opened this issue Feb 3, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@f1w3
Copy link

f1w3 commented Feb 3, 2023

While I was using this library, I encountered a problem that I couldn't solve.

const client = new Client({
    token: token,
    replId: replId
})
await client.connect()

The following error occurs when executing

not implemented: ClientRequest.setTimeout
error: Uncaught Error: Unexpected token 'P', "POST body "... is not valid JSON
    at new ApolloError (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:5582:28)
    at file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:7232:19
    at both (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1702:53)
    at file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1695:72
    at new Promise (<anonymous>)
    at Object.then (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1695:24)  
    at Object.error (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1703:49) 
    at notifySubscription (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1119:18)
    at onNotify (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1158:3)      
    at SubscriptionObserver.error (file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:1211:5)

I understand that I shouldn't use deno, but I can't fix it myself (and I don't know the cause of the error), so I opened an issue

@rayhanadev
Copy link
Owner

How curious, while yes this library is built for Node.js and not Deno, the error doesn't seem to be with crosis4furrets itself, but a library it consumes (that I made) called @rayhanadev/replit-gql which is a wrapper around Apollo Client GraphQL but uses patched headers and node-fetch so it'll work on server.

I'm not quite sure what the error is there, it might be work looking into how @apollo/client and node-fetch behave in Deno. If I do come across a fix I will implement it!

@rayhanadev rayhanadev added the bug Something isn't working label Feb 3, 2023
@rayhanadev
Copy link
Owner

Presumably, this could be fixed by altering my GraphQL library and crosis4furrets into using their Web API equivalents because those are available in Deno... will see what I can do 😆.

@f1w3
Copy link
Author

f1w3 commented Feb 4, 2023

I have located where the problem is occurring.
In @rayhanadev/replit-gql, in dist/index.mjs, at line 2112:25

{
  networkError: ServerParseError: Unexpected token 'P', "POST body "... is not valid JSON
    at JSON.parse (<anonymous>)
    at file:///C:/Users/user/AppData/Local/deno/npm/registry.npmjs.org/@rayhanadev/replit-gql/1.2.1/dist/index.mjs:2112:25
    at Object.runMicrotasks (deno:core/01_core.js:397:30)
    at processTicksAndRejections (https://deno.land/std@0.176.0/node/_next_tick.ts:62:10)
}

seems to be the problem
If I check the variable bodyText

POST body missing, invalid Content-Type, or JSON object has no keys.

I found that the above error occurs because the above characters are stored and JSON.parse() is used to parse them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants