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

Bug: CF Pages SSR with SurrealJS fails #214

Open
2 tasks done
itsezc opened this issue Feb 9, 2024 · 2 comments
Open
2 tasks done

Bug: CF Pages SSR with SurrealJS fails #214

itsezc opened this issue Feb 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@itsezc
Copy link

itsezc commented Feb 9, 2024

Describe the bug

Using surrealdb.js on Cloudflare Pages platform with SSR just fails on SvelteKit 2, I have to pass the following to the root layout:

export const csr = true;
export const ssr = false;

for it to work, but this is not ideal as it disables SSR and ISR.

Steps to reproduce

Setup SvelteKit with surrealdb.js and deploy as an SSR site

Expected behaviour

Have SSR working

SurrealDB version

v1.1.1

SurrealDB.js version

0.11.0

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@itsezc itsezc added the bug Something isn't working label Feb 9, 2024
@itsezc
Copy link
Author

itsezc commented Apr 16, 2024

While running into the issue with DevTools, heres what you get:

A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
Uncaught (in response) Error: The script will never generate a response.

Upon debugging further:

Error: Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response bodies, and others) created in the context of one request handler cannot be accessed from a different request's handler. This is a limitation of Cloudflare Workers which allows us to improve overall performance.
    at _SurrealSocket.send (SurrealSocket.ts:133:12)
#options.hooks.handleError @ index.js:2903
handle_error_and_jsonify @ index.js:174
render_page @ index.js:2090

@raymonddaikon
Copy link

I'm having the same issue with CloudFlare workers (via Partykit). Making a db call using the client library hangs indefinitely. I'm not sure whether or not it's an issue with serialization or the ws protocol. A reproduction can be created with a starter template and adding an onStart surrealdb.js call function

  async onStart() {
    this.surrealClient = new Surreal()
    await this.surrealClient.connect(this.room.env.SURREALDB_URL as string, {
      auth: {
        namespace: 'ns',
        database: 'db',
        username: 'root'
        password: 'root',
        scope: undefined,
      },
    })
    await this.surrealClient.query()
  }

anywhere in /party/chatrooms.ts

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