Skip to content

Improve Firebase getDataOnce handling - #2

Open
Todo18 wants to merge 1 commit into
mainfrom
codex/update-getdataonce-for-snapshot.exists
Open

Improve Firebase getDataOnce handling#2
Todo18 wants to merge 1 commit into
mainfrom
codex/update-getdataonce-for-snapshot.exists

Conversation

@Todo18

@Todo18 Todo18 commented Nov 14, 2025

Copy link
Copy Markdown
Owner

Summary

  • update getDataOnce to use snapshot.exists() and throw on Firebase errors
  • add unit tests covering existing data, missing data, and error scenarios

Testing

  • yarn test (fails: Yarn install blocked by proxy)

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread services/firebase/api.js
Comment on lines +12 to +23
export async function getDataOnce(path) {
try {
const snapshot = await get(child(ref(db), path))

if (!snapshot?.exists())
return false

return snapshot.val()
}
catch (error) {
console.error(error?.message ?? error)
throw error

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid rejecting from getDataOnce without caller handling

The new catch block rethrows Firebase errors (getDataOnce now rejects instead of resolving a falsy value). Existing callers such as store/currencies/actions.ts:initCurrencies and store/lang/actions.js:initDbLang rely on the old behaviour where failures simply returned undefined and the code fell back to defaults or alternate data sources. Because those dispatches are not awaited or wrapped in try/catch, any transient database error will now short‑circuit the actions and surface as unhandled promise rejections, leaving currencies/lang uninitialized. Either revert to resolving a sentinel value or update the call sites to catch and handle the rejection.

Useful? React with 👍 / 👎.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant