firebase / firebase/firebase-tools

Emulator error `Error: socket hang up`

Open
#6,628 26 comments 5 reactions 1 assignee Assigned to @ajperel View on GitHub
emulators: functions type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

On my m1 mac, I get the following error when emulating a function with the BigQuery python SDK:

```
> objc[122]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
> objc[122]: +[__NSCFConstantString 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.
⬢ functions: Failed to handle request for function us-central1-commontrees
⬢ functions: Failed to start functions in /Users/jhuleatt/projects/io-python/functions: Error: socket hang up
```

here's the function code:

```python
from firebase_functions import https_fn
from google.cloud import bigquery
import json

@https_fn.on_request(timeout_sec=20)
def commontrees(req: https_fn.Request) -> https_fn.Response:
client = bigquery.Client()
query = """
SELECT spc_latin, spc_common, COUNT(spc_latin) as num_specimens
FROM `bigquery-public-data.new_york_trees.tree_census_2015`
WHERE SPC_LATIN <> ''
GROUP BY spc_latin, spc_common
ORDER BY num_specimens DESC
LIMIT 50
"""
query_job = client.query(query)

common_trees = [];
for row in query_job:
common_trees.append({
"scientificName": row['spc_latin'],
"commonName": row['spc_common'],
"count": row['num_specimens']
})
return https_fn.Response(json.dumps(common_trees), mimetype='application/json')
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.