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

Awaiting an action in the client setup function prevents render #2097

Open
sodic opened this issue Jun 12, 2024 · 3 comments
Open

Awaiting an action in the client setup function prevents render #2097

sodic opened this issue Jun 12, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@sodic
Copy link
Contributor

sodic commented Jun 12, 2024

Steps to reproduce:

  1. Go to waspc/todoApp/src/clientSetup.js.
  2. Make the function async and await an action inside (e.g., testingAction)
  3. Run wasp start, load localhost:3000 and see the blank white screen.

Code confirmed to cause the behavior:

import { testingAction } from 'wasp/client/operations'
import { sayHi } from './util'

export default async function setup() {
  console.log('This was called from the client setup function')
  await testingAction()
  sayHi()
}
@sodic sodic added the bug Something isn't working label Jun 12, 2024
@Martinsos
Copy link
Member

Martinsos commented Jun 12, 2024

@sodic why would this be a bug? It sounds to me like it is expected behaviour -> you put await in setup function for a client, of course rendering it postponed.

Here is from our docs about this function:

setupFn declares a Typescript function that Wasp executes on the client before everything else. It is expected to be asynchronous, and Wasp will await its completion before rendering the page. The function takes no arguments, and its return value is ignored.

You can use this function to perform any custom setup (e.g., setting up client-side periodic jobs).

So I would say this is expected, documented and desired behaviour! If you want to not wait for that action, you can just not await it.

@sodic
Copy link
Contributor Author

sodic commented Jun 12, 2024

@Martinsos The rendering isn't postponed, it never happens.

@Martinsos
Copy link
Member

@Martinsos The rendering isn't postponed, it never happens.

Whoops! Ok, that is really weird!

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