GithubHelp home page GithubHelp logo

Timeout during query merge about fauna-js HOT 9 CLOSED

fauna avatar fauna commented on June 3, 2024
Timeout during query merge

from fauna-js.

Comments (9)

ptpaterson avatar ptpaterson commented on June 3, 2024 1

We are still investigating the issue with .take(1).paginate(9999). But the Message.where(.role) is more likely working correctly.

The where predicate is allowed to return null and if it does so, then it is treated as false. When you run something like Message.where(.role) the expectation is that the field role is either null (missing) or a boolean value. The query starts scanning the entire Collection and resolving the role field.

.role is a key that only exist in one doc and is missing in all the other ones.

Note that the default query-timeout is 5 seconds. In this case, it is most likely that Fauna simply spent more than 5 seconds scanning, looking for a document with a role field, and found none. If it had found the one document, you would be more likely to get a 400 error with a message like error: expected type: Boolean, received String or similar.

from fauna-js.

zvictor avatar zvictor commented on June 3, 2024

This query is also throwing the same error, but every single time:

fql`Message.where(.role)`

Same for

fql`Message.all().where(.role)`

.role is a key that only exist in one doc and is missing in all the other ones.
I tried different names of non existent keys and they all throw the same error.

from fauna-js.

ptpaterson avatar ptpaterson commented on June 3, 2024

This is not an issue with the driver: the driver is correctly handling the 503 error returned by the database. The fact that it is timing out is an issue with the database, though.

This is possibly related to this forums topic: https://forums.fauna.com/t/fqlv10-comparison-of-objects-never-completes/3652

Where the issue is the DB hanging on a comparison between non-comparable types.

In your case, you're not providing a boolean value to .where. FQL types don't have a "truthiness" value like javascript. You need to explicitly check

fql`Message.where(.role != null)`

from fauna-js.

ptpaterson avatar ptpaterson commented on June 3, 2024

Closing this, but will make a note to follow up here regarding the DB issue.

from fauna-js.

zvictor avatar zvictor commented on June 3, 2024

Thanks for all the info, @ptpaterson !
I have set a big query-timeout and the original error disappeared, but now I am faced with NetworkError: The network connection encountered a problem.

Config:

const client = new Client({
  query_timeout_ms: 60_000,
  http2_session_idle_ms: 60_000,
})

await client.query(fql`Message.all().where(m => m.service == ${service}).paginate(9999)`)

Error:

{
  query: {
    fql: [
      'Message.all().where(m => m.service == ',
      [Object],
      ').paginate(9999)'
    ]
  },
  arguments: undefined
}


/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/http-client/node-http2-client.ts:94
          throw new NetworkError(
                ^
NetworkError: The network connection encountered a problem.
    at _NodeHTTP2Client.request (/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/http-client/node-http2-client.ts:94:17)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _Client.query_fn (/node_modules/.pnpm/fauna@0.9.0/node_modules/fauna/src/client.ts:385:9)
    at async fetchMessages (file:///data-science/fetch-data.ts:15:18)
    at async processService (file:///data-science/fetch-data.ts:27:18)
    at async file:///data-science/fetch-data.ts:68:1 {
  [cause]: Error [ERR_HTTP2_STREAM_ERROR]: Stream closed with error code NGHTTP2_INTERNAL_ERROR
      at new NodeError (node:internal/errors:377:5)
      at ClientHttp2Stream._destroy (node:internal/http2/core:2339:13)
      at _destroy (node:internal/streams/destroy:109:10)
      at ClientHttp2Stream.destroy (node:internal/streams/destroy:71:5)
      at Http2Stream.onStreamClose (node:internal/http2/core:549:12) {
    code: 'ERR_HTTP2_STREAM_ERROR'
  }
}

from fauna-js.

cleve-fauna avatar cleve-fauna commented on June 3, 2024

Reopening as @zvictor has asked another question.

from fauna-js.

cleve-fauna avatar cleve-fauna commented on June 3, 2024

@zvictor that idle timeout is quite aggressive. That will attempt to hold an open, but unused http2 session to Fauna for 60s. I would be surprised if Fauna is willing to do the same on the http2 session. I am speculating that that may be the cause of the NetworkError; as Fauna may simply be hanging up on you.

Can you try this without setting that timeout (and thus using the driver's default of 5s)?

There's some basis in the Node docs for this theory as well: https://nodejs.org/api/http2.html#destruction

from fauna-js.

zvictor avatar zvictor commented on June 3, 2024

Can you try this without setting that timeout (and thus using the driver's default of 5s)?

I won't be able to work on the project I was working on for quite a while. Once I do, I can check it out, but not before that. I am sorry.

Feel free to close the issue once again.

from fauna-js.

cleve-fauna avatar cleve-fauna commented on June 3, 2024

Please reopen if you want more help with this.

from fauna-js.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.