firebase Firestore模拟器无法清理GitHub操作中的数据

9udxz4iz  于 2023-04-13  发布在  Git
关注(0)|答案(1)|浏览(132)

我有一个测试,在我的本地机器上运行得很顺利,过去它经常在GitHub操作中完成。
现在,当我在每个测试运行后调用API删除Firestore模拟器中的现有数据时,它会失败。
我收到了以下信息

⚠  Authenticating with `FIREBASE_TOKEN` is deprecated and will be removed in a future major version of `firebase-tools`. Instead, use a service account key with `GOOGLE_APPLICATION_CREDENTIALS`: https://cloud.google.com/docs/authentication/getting-started
i  emulators: Starting emulators: auth, functions, firestore, pubsub, storage
i  emulators: Detected demo project ID "demo-test", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.
⚠  functions: You are not signed in to the Firebase CLI. If you have authorized this machine using gcloud application-default credentials those may be discovered and used to access production services.
⚠  It appears you are running in a CI environment. You can avoid downloading the Firestore Emulator repeatedly by caching the /home/runner/.cache/firebase/emulators directory.
i  firestore: downloading cloud-firestore-emulator-v1.16.2.jar...
i  firestore: Firestore Emulator logging to firestore-debug.log
✔  firestore: Firestore Emulator UI websocket is running on 9150.
⚠  It appears you are running in a CI environment. You can avoid downloading the Pub/Sub Emulator repeatedly by caching the /home/runner/.cache/firebase/emulators directory.
i  pubsub: downloading pubsub-emulator-0.7.1.zip...
i  pubsub: Pub/Sub Emulator logging to pubsub-debug.log
⚠  It appears you are running in a CI environment. You can avoid downloading the Storage Emulator repeatedly by caching the /home/runner/.cache/firebase/emulators directory.
i  storage: downloading cloud-storage-rules-runtime-v1.1.3.jar...
i  functions: Watching "/home/runner/work/entropic-bond-firebase/entropic-bond-firebase/functions" for Cloud Functions...
✔  functions: Using node@18 from host.
✔  functions: Loaded functions definitions from source: test, testCallablePersistent, testCallablePlain.
✔  functions[europe-west1-test]: http function initialized (http://127.0.0.1:5001/demo-test/europe-west1/test).
✔  functions[europe-west1-testCallablePersistent]: http function initialized (http://127.0.0.1:5001/demo-test/europe-west1/testCallablePersistent).
✔  functions[europe-west1-testCallablePlain]: http function initialized (http://127.0.0.1:5001/demo-test/europe-west1/testCallablePlain).
i  Running script: jest --forceExit
FAIL src/store/firebase-datasource.spec.ts (11.628 s)
  ● Firestore Model › should find document by id
    TypeError: fetch failed
      43 |  afterEach( async ()=>{
      44 |      await terminate( FirebaseHelper.instance.firestore() )
    > 45 |      await fetch( 'http://localhost:9080/emulator/v1/projects/demo-test/databases/(default)/documents', {
         |      ^
      46 |          method: 'DELETE'
      47 |      })
      48 |  })
      at Object.<anonymous> (src/store/firebase-datasource.spec.ts:45:3)
    Cause:
    connect ECONNREFUSED ::1:9080

我试过127.0.0.1像其他评论中建议的那样获取www.example.com而不是localhost,但这只会得到一个超时和无用的反馈。
有什么想法吗

zazmityj

zazmityj1#

这个问题源于Node v18.x在ipv4之前更喜欢ipv6这一事实
您可以通过拨打以下电话来解决此问题

dns.setDefaultResultOrder('ipv4first')

在你档案的开头
见https://github.com/node-fetch/node-fetch/issues/1624#issuecomment-1407717012

相关问题