Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase: broken pipe when using npm #28610

Open
jsafarik opened this issue Mar 24, 2025 · 0 comments
Open

Firebase: broken pipe when using npm #28610

jsafarik opened this issue Mar 24, 2025 · 0 comments

Comments

@jsafarik
Copy link

Version: Deno 2.2.5

I've been playing around with Deno and Firebase/Firestore, put together a short script:

import "https://deno.land/x/[email protected]/mod.ts";
import { deleteApp, initializeApp } from "npm:firebase/app";
import { collection, getDocs, getFirestore } from "npm:firebase/firestore";

const firebaseConfig = JSON.parse(Deno.env.get("FIREBASE_CONFIG"));
const firebaseApp = initializeApp(firebaseConfig);
const db = getFirestore(firebaseApp);

(await getDocs(collection(db, "sample-collection"))).docs.forEach((doc) => {
  console.log(doc.data());
});

await deleteApp(firebaseApp);

which, if I run (locally or in docker container), I get the following:

export FIREBASE_CONFIG='<CONFIG>' && deno run --node-modules-dir --allow-scripts=npm:@firebase/[email protected],npm:[email protected] --allow-env --allow-net test.js
{ "sample-field": "sample-value" }
error: Uncaught (in promise) Error: stream closed because of a broken pipe
    at async node:http2:824:44

now if I change the imports to esm.sh ones, the issue with broken pipe goes away:

import "https://deno.land/x/[email protected]/mod.ts";
import { deleteApp, initializeApp } from "https://esm.sh/[email protected]/app";
import { collection, getDocs, getFirestore } from "https://esm.sh/[email protected]/firestore";

const firebaseConfig = JSON.parse(Deno.env.get("FIREBASE_CONFIG"));
const firebaseApp = initializeApp(firebaseConfig);
const db = getFirestore(firebaseApp);

(await getDocs(collection(db, "sample-collection"))).docs.forEach((doc) => {
  console.log(doc.data());
});

await deleteApp(firebaseApp);

the output is:

export FIREBASE_CONFIG='<CONFIG>' && deno run --allow-env --allow-net test.js
{ "sample-field": "sample-value" }

(no broken pipe, the exit status is 0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant