Skip to content

ECONNRESET connecting to Firebase auth emulator from functions emulator with grpc imported #945

Open

Description

@danielparks

[READ] Step 1: Are you in the right place?

I’m not sure that the root cause of this issue is, but this repo seems like the most likely culprit. Other possibilities: gRPC, firebase-tools, firebase-functions.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: macOS 15.7.4 (24G517)
  • Firebase SDK version: 7.4.0
  • Firebase Product: auth
  • Python version: 3.11.15
  • Pip version: uv 0.11.6

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

danielparks/firebase-emulator-auth-hang-up is minimal test repo with more exhaustive details including a workaround.

Within a Python cloud function that has grpc or firebase_admin.firestore imported, call an auth method, e.g. auth.create_user(...), or make a GET request to the auth endpoint, e.g. requests.get("http://127.0.0.1:9099/", timeout=1).

The function will fail with ECONNRESET (“Error: socket hang up”).

Relevant Code:

Simplified example (see the repo above for a functional example):

from firebase_admin import initialize_app
from firebase_functions import https_fn
import requests

import grpc
# or, import firebase_admin.firestore

initialize_app()

@https_fn.on_call()
def connect(req):
    # Make a simple GET request to the auth emulator endpoint:
    return repr(requests.get("http://127.0.0.1:9099/", timeout=1))

Activity

  1. bryancalisto commented on May 15, 2026

    @bryancalisto

    Similar thing here. This code fails in auth.verify_id_token (there's not something explicitly telling that it failed. I just never see the print('4')) when calling process_stuff through firebase emulators:start --only functions and get the error below:

    from firebase_admin import auth, initialize_app, firestore
    from firebase_functions import https_fn
    from loguru import logger
    import os
    from functools import wraps
    import base64
    import json
    from datetime import datetime, timezone
    from fn_impl.utils import ConsumablesError, Entity
    from firebase_functions.params import SecretParam
    
    
    def authenticate(f):
        @wraps(f)
        def decorated_function(req: https_fn.Request, *args, **kwargs):
            print('1')
            auth_header = req.headers.get('Authorization')
            if not auth_header or not auth_header.startswith('Bearer '):
                return https_fn.Response(
                    "Invalid credentials",
                    status=401
                )
    
            print('2')
    
            try:
                id_token = auth_header.split('Bearer ')[1]
                print('3')
                decoded_token = auth.verify_id_token(id_token)
                print('4')
    
                req.user = decoded_token
            except Exception as e:
                logger.error(f"Authentication failed: Unexpected error: {e}")
                return https_fn.Response(
                    "Error verifying credentials",
                    status=401
                )
    
            return f(req, *args, **kwargs)
        return decorated_function
    
    @https_fn.on_request()
    @authenticate
    def process_stuff(req: https_fn.Request):
    ...

    ERRORS:

    >  objc[60961]: +[NSNumber initialize] may have been in progress in another thread when fork() was called.
    >  objc[60961]: +[NSNumber initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
    i  Request to function failed: Error: read ECONNRESET
    >  [2026-05-15 18:57:32 +0000] [60960] [ERROR] Worker (pid:60961) was sent SIGKILL! Perhaps out of memory?
    

    I guess it's not memory related as there's more than 7 GB of free memory when the error triggers.

    I got the ECONNRESET (“Error: socket hang up”) a couple of times too, but not sure with which version of firebase-admin it was as I was testing with 7.2.0 and 7.0.4 .

    My requirements.txt looks like

    firebase-admin==7.4.0
    firebase-functions==0.5.0
    loguru==0.7.3

    firebase-tools version is 15.18.0

    Python version is 3.11.14.

    My system runs macos Tahoe 26.3.1 (M4).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions