Code Monkey home page Code Monkey logo

Comments (5)

posva avatar posva commented on June 22, 2024

Your useDocument() shouldn't be inside an asyncData: https://vuefire.vuejs.org/guide/realtime-data.html

from vuefire.

harrycheung avatar harrycheung commented on June 22, 2024

@posva

I've amended the repro, and I still get the behavior:

Nuxt 3.11.1 with Nitro 2.9.4                                                11:58:40 AM
[11:58:40 AM] [get-port] Unable to find an available port (tried 3000 on host "localhost"). Using alternative port 3001.
                                                                            11:58:40 AM
  ➜ Local:    http://localhost:3001/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Option + D in the browser (v1.1.3)              11:58:40 AM

ℹ Vite client warmed up in 818ms                                           11:58:42 AM
✔ Nuxt Nitro server built in 758 ms                                  nitro 11:58:42 AM
ℹ Vite server warmed up in 1475ms                                          11:58:42 AM

 WARN  [nuxt] #imports should be transformed with real imports. There seems to be something wrong with the imports plugin.

useDocument 2024-03-21T18:59:02.424Z
handle: undefined
useDocument 2024-03-21T18:59:06.634Z
handle: gate-remover-set

from vuefire.

posva avatar posva commented on June 22, 2024

I don't know what you are trying to achieve but I tested locally after updating packages and it works. You don't need to await the promise either, consume the product directly in the template. VueFire uses onServerPrefetch() to await it.

Cheers.

from vuefire.

harrycheung avatar harrycheung commented on June 22, 2024

Thanks @posva for making an attempt at reproduction. I've amended the repro as you suggested (and tried with just the emulators), but the behavior is still happening. The first time I fetch a specific document id using useDocument(), it returns undefined. Subsequent fetches for that same document id succeed. I want the first request to be successful.

As you pointed out in previous iterations, my usage may be at fault here. I've tried to simplify things as much as possible to make it easy to reproduce, so it confounds me that you can't.

Here's what I'm doing:

  1. I start the emulators
  2. I added the following data to Firestore. Screenshot 2024-03-22 at 8 29 11 AM
  3. I start the server.
  4. I point my browser to http://localhost:3000, and my output is as follows:
harry@hankBookPro16 nuxt--vuefire-repro-template % yarn dev
yarn run v1.22.21
$ nuxt dev
Nuxt 3.11.1 with Nitro 2.9.4                                                                                                 8:28:05 AM
                                                                                                                             8:28:05 AM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Enabling auth emulator at 127.0.0.1:9099                                                              nuxt-vuefire module 8:28:05 AM
ℹ Enabling database emulator at 127.0.0.1:9001                                                          nuxt-vuefire module 8:28:05 AM
ℹ Enabling firestore emulator at 127.0.0.1:8081                                                         nuxt-vuefire module 8:28:05 AM
ℹ Enabling storage emulator at 127.0.0.1:9199                                                           nuxt-vuefire module 8:28:05 AM
  ➜ DevTools: press Shift + Option + D in the browser (v1.1.3)                                                               8:28:05 AM

ℹ Vite client warmed up in 1049ms                                                                                           8:28:07 AM
✔ Nuxt Nitro server built in 461 ms                                                                                   nitro 8:28:07 AM
ℹ Vite server warmed up in 1452ms                                                                                           8:28:07 AM

 WARN  [nuxt] #imports should be transformed with real imports. There seems to be something wrong with the imports plugin.

[nuxt-vuefire] ℹ Storage emulator connected to http://127.0.0.1:9199
[nuxt-vuefire] ℹ Firestore emulator connected to http://127.0.0.1:8081
[nuxt-vuefire] ℹ Database emulator connected to http://127.0.0.1:9001
ℹ WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials.
[nuxt-vuefire] ℹ Auth emulator connected to http://127.0.0.1:9099
useDocument 2024-03-22T15:28:11.036Z
handle: undefined
  1. I refresh my browser tab pointed at http://localhost:3000, and my output adds the last two lines:
harry@hankBookPro16 nuxt--vuefire-repro-template % yarn dev
yarn run v1.22.21
$ nuxt dev
Nuxt 3.11.1 with Nitro 2.9.4                                                                                                 8:28:05 AM
                                                                                                                             8:28:05 AM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Enabling auth emulator at 127.0.0.1:9099                                                              nuxt-vuefire module 8:28:05 AM
ℹ Enabling database emulator at 127.0.0.1:9001                                                          nuxt-vuefire module 8:28:05 AM
ℹ Enabling firestore emulator at 127.0.0.1:8081                                                         nuxt-vuefire module 8:28:05 AM
ℹ Enabling storage emulator at 127.0.0.1:9199                                                           nuxt-vuefire module 8:28:05 AM
  ➜ DevTools: press Shift + Option + D in the browser (v1.1.3)                                                               8:28:05 AM

ℹ Vite client warmed up in 1049ms                                                                                           8:28:07 AM
✔ Nuxt Nitro server built in 461 ms                                                                                   nitro 8:28:07 AM
ℹ Vite server warmed up in 1452ms                                                                                           8:28:07 AM

 WARN  [nuxt] #imports should be transformed with real imports. There seems to be something wrong with the imports plugin.

[nuxt-vuefire] ℹ Storage emulator connected to http://127.0.0.1:9199
[nuxt-vuefire] ℹ Firestore emulator connected to http://127.0.0.1:8081
[nuxt-vuefire] ℹ Database emulator connected to http://127.0.0.1:9001
ℹ WARNING: You are using the Auth Emulator, which is intended for local testing only.  Do not use with production credentials.
[nuxt-vuefire] ℹ Auth emulator connected to http://127.0.0.1:9099
useDocument 2024-03-22T15:28:11.036Z
handle: undefined
useDocument 2024-03-22T15:28:19.448Z
handle: handle1

from vuefire.

harrycheung avatar harrycheung commented on June 22, 2024

Hi @posva, can you take another look? I've added some more context.

from vuefire.

Related Issues (20)

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.