firebase/firebase-js-sdk

Testing Cloud Firestore on Emulator - Timeout for every call

Closed this issue · 5 comments

[REQUIRED] Describe your environment

  • Operating System version: Windows 10
  • Browser version: NA
  • Firebase SDK version: 8.0.3
  • Firebase Product: Firestore and Emulator

[REQUIRED] Describe the problem

I tryed this Fireship Tutorial to learn how to use the emulator and had an issue that every call to the firebase.assertSucceeds and firebase.assertFails had a Timeout response.

So I tryed the Cloud Firestore emulator quickstart and had the same issue.

I found this issue #2305 that is the same as I am having.
On this issue it says that updating the @firebase/testing to 0.15.0 solved the issue. But this is the version used on the guide. I updated to the version 0.15.1 but it did not solve the issue.

I also disabled my antivirus with no changes.

Some logs:

Starting the emulator:

i  emulators: Starting emulators: firestore
i  firestore: firestore emulator logging to firestore-debug.log
+  firestore: firestore emulator started at http://localhost:8080
i  firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080
+  emulators: All emulators started, it is now safe to connect.

Running the tests:

My app
   1) require users to log in before creating a profile
   2) should enforce the createdAt date in user profiles
   3) should only let users create their own profile
   4) should let anyone read any profile
[2020-04-16T15:22:22.228Z]  @firebase/firestore: Firestore (7.4.0): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.
   5) should let anyone create a room
   6) should force people to name themselves as room owner when creating a room
   7) should not let one user steal a room from another user

View rule coverage information at http://localhost:8080/emulator/v1/projects/firestore-emulator-example:ruleCoverage.html


 0 passing (1m)
 7 failing

 1) My app
      require users to log in before creating a profile:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

 2) My app
      should enforce the createdAt date in user profiles:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

 3) My app
      should only let users create their own profile:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

 4) My app
      should let anyone read any profile:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

 5) My app
      should let anyone create a room:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

 6) My app
      should force people to name themselves as room owner when creating a room:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

 7) My app
      should not let one user steal a room from another user:
    Error: Timeout of 10000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (D:\Projetos\Projetos Exemplos\quickstart-nodejs-master\firestore-emulator\javascript-quickstart\test\test.js)
     at listOnTimeout (internal/timers.js:549:17)
     at processTimers (internal/timers.js:492:7)

The firebase-debug.log file:

API endpoint: http://localhost:8080
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

   export FIRESTORE_EMULATOR_HOST=localhost:8080

Dev App Server is now running.

Apr 16, 2020 12:21:35 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
Apr 16, 2020 12:21:37 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
Apr 16, 2020 12:21:50 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
Apr 16, 2020 12:22:02 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
INFO: Detected HTTP/2 connection.
Apr 16, 2020 12:22:52 PM io.netty.channel.DefaultChannelPipeline onUnhandledInboundException
WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.io.IOException: An existing connection was forcibly closed by the remote host
	at sun.nio.ch.SocketDispatcher.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(Unknown Source)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
	at sun.nio.ch.IOUtil.read(Unknown Source)
	at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
	at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1133)
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Unknown Source)

Apr 16, 2020 12:22:52 PM io.netty.channel.DefaultChannelPipeline onUnhandledInboundException
WARNING: An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.io.IOException: An existing connection was forcibly closed by the remote host
	at sun.nio.ch.SocketDispatcher.read0(Native Method)
	at sun.nio.ch.SocketDispatcher.read(Unknown Source)
	at sun.nio.ch.IOUtil.readIntoNativeBuffer(Unknown Source)
	at sun.nio.ch.IOUtil.read(Unknown Source)
	at sun.nio.ch.SocketChannelImpl.read(Unknown Source)
	at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1133)
	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Unknown Source)

Steps to reproduce:

Just follow the Cloud Firestore emulator quickstart guide
Instead of using the requested command to run the tests
firebase emulators:exec --only firestore 'npm test'
I used this on a terminal
firebase emulators:start --only firestore
and on another terminal I used
npm test

Relevant Code:

Literally the Cloud Firestore emulator quickstart guide.

Same here, it worked good before last release,i didnt change the code and having same issue, i can send call via postman but not via:

const functionName = await firebase
      .functions()
      .httpsCallable('functionName')

as i inspect request it doesnt have "POST" method, leading to a time out.

@alansn25 I'm not able to see the error you're seeing. I just did:

  • A fresh clone of quickstart-nodejs
  • cd quickstart-nodejs/firestore-emulator/javascript-quickstart
  • npm install
  • npm install firebase-tools
  • node_modules/.bin/firebase emulators:exec --only firestore 'npm test'

... and got the expected output. I'm able to see this on both macOS Catalina and Windows 10.

Changing this to make the emulator start separate from npm test separate didn't change anything.

On Windows, I did get a prompt for whether or not Windows Defender Firewall should allow java to accept connections. Make sure you haven't denied this permission.

@Albertbol your issue with Firebase Functions sounds different, please file a new issue with everything you're doing trying to reproduce the issue.

Thanks for trying.
My antivirus is Kaspersky, I disabled everything from Kaspersky and the windows firewall and did not solve the issue. So I uninstalled the Kaspersky entirely from my computer and it started to work.

So basically Kaspersky was blocking in some way and I only managed to bypass by uninstalling it. I will check if there is some configuration that allows it to work.

Even if I disable every single component from Kaspersky and add the cloud-firestore-emulator-v1.11.3.jar to the trusted list it does not work. It only works if I close the Kaspersky completely.

If I search the web for Kaspersky blocks localhost I see there are plenty of issues people are having, and how to solve this may depend on which edition and version of the product you have. We can't really support you in this--we don't use Kaspersky ourselves.

I will note that generally, when unblocking applications (rather than specific ports), you have to add the executable that runs the process rather than any data it's using. In the case of the Firestore emulator, we distribute a JAR file but the executable is actually the Java Virtual Machine. Try adding the java.exe that ends up being invoked to your trusted list.