question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

when SwcMinify true , firestore(firebase) cannot getting data on build and serve

See original GitHub issue

What version of Next.js are you using?

12.0.4

What version of Node.js are you using?

16.13.0

What browser are you using?

chrome

What operating system are you using?

macOS

How are you deploying your application?

next start

Describe the Bug

i tried create next app , and set config next with swcMinify: true

when I use firebase-firestore to fetch data while dev is running smoothly.

but when i do build the result from firestore can be undefined

Expected Behavior

should result from build and dev produce the same

To Reproduce

import { useEffect } from "react";
import Link from "next/link";
import { initializeApp, getApps, getApp } from "firebase/app";
import { getFirestore, getDoc, doc } from "@firebase/firestore";

const app = !getApps().length
  ? initializeApp({})
  : getApp();
const store = getFirestore(app);

export default function IndexPage() {
  const testRequest = async () => {
    try {
      // if run with dev will run fine and will get result from firestore
      // if run with build and start , it will only get undefined
      const result = await getDoc(doc(store, "users", "testid"));
      console.log("test result", { docSnap: result.data() });
    } catch (error) {
      console.log(error)
    }
  };

  useEffect(() => {
    testRequest();
  }, []);

  return (
    <div>
      Hello World.{" "}
      <Link href="/about">
        <a>About</a>
      </Link>
    </div>
  );
}
//next-config.js
const config = {
  swcMinify:true
};
module.exports = config;

sample when i run dev Screen Shot 2021-11-23 at 12 40 12

sample when i run build start Screen Shot 2021-11-23 at 12 39 47

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Aliemekacommented, Nov 24, 2021

@timneutkens can you check this out too? Seems to be another swcMinify issue. Does the next@canary release address this as well?

0reactions
github-actions[bot]commented, Feb 20, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get data with Cloud Firestore - Firebase
There are three ways to retrieve data stored in Cloud Firestore. Any of these methods can be used with documents, collections of documents,...
Read more >
Next.js production: CANNOT READ DATA FROM FIRESTORE
So my firestore configuration is fine, the code is fine, and there's nothing wrong with the deployment server. Since there's nothing wrong with ......
Read more >
Querying and filtering data | Firestore - Google Cloud
Firestore provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group.
Read more >
Next.js and Firebase Tutorial – How to Build an Evernote Clone
Next.js is a server-side rendering framework based on React, which is search engine ... Now, let's send our data to the Firebase Firestore....
Read more >
Cloud Firestore | Flutter Firestore CRUD | Flutter Firestore Tutorial
We'll learn about cloud firestore. Learn CRUD operations in flutter firestore. Cloud Firestore is a realtime database provide by Firebase and learn how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found