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

TypeError: childPathObj.split is not a function at pathChild #8065

Open
AlastairTaft opened this issue Mar 13, 2024 · 0 comments
Open

TypeError: childPathObj.split is not a function at pathChild #8065

AlastairTaft opened this issue Mar 13, 2024 · 0 comments

Comments

@AlastairTaft
Copy link

AlastairTaft commented Mar 13, 2024

Operating System

MacOS 14.2 (23C64)

Browser Version

Chrome 122.0.6261.112

Firebase SDK Version

10.8.1

Firebase SDK Product:

Database

Describe your project's tooling

Node CommonJS server.

Describe the problem

When running a set command I receive the error.

TypeError: childPathObj.split is not a function
    at pathChild (/REDACTED/node_modules/@firebase/database-compat/dist/index.standalone.js:6429:40

Steps and code to reproduce issue

The only reason I'm creating this ticket is because the one I wanted to leave a comment on is locked and closed.

I wanted to shed some light on what I think the issue is.

The error happens because the check childPathObj instanceof Path in node_modules/@firebase/database-compat/dist/index.standalone.js comes back as false when it should be true. It's on line 6421

problem code

Two different instances of Path are existing, maybe it's because I'm mixing firebase-admin with firebase.

The childPathObj is being instantiated by the Path class in the file node_modules/@firebase/database/dist/index.node.cjs.js but at this point where we error we're running the code in node_modules/@firebase/database-compat/dist/index.standalone.js

sample code

var { ref, set } = require("firebase/database")
var { getDatabase } = require("firebase-admin/database")
var { cert, initializeApp } = require('firebase-admin/app')
var admin = require('firebase-admin')

const run = async function(){
  var serviceAccount = require('../firebaseServiceAccountKey')
  await initializeApp({
    credential: cert(serviceAccount),
    databaseURL: process.env.FIREBASE_DB_URL
  })
  const db = getDatabase()
  await set(ref(db, `/test/path`), 'abc')
  await admin.app().delete()
}
run()

package.json

{
  "dependencies": {
    "firebase": "^10.8.1",
    "firebase-admin": "12",
    "@firebase/database-compat": "1.0.3"
  }
}

Perhaps this check could be a bit more forgiving. Or a warning when multiple versions are in use could be helpful. I think it's an incompatibility with using the admin sdk (which loads the 'compat' code) with the v9 normal sdk (I've tried to hack it to make it work without success). It would be helpful if there were some docs on how to use the modular sdk server side, or a definitive warning that its not possible, or a solution so the packages are compatible. I think the reason I've ended up in this mess is because I have a lot of v9 modular code written client side which I've copied over to a script I'm trying to run on the backend. From what I can tell I don't think this will ever work and I need to write non modular code for my backend scripts.

@AlastairTaft AlastairTaft added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Mar 13, 2024
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Mar 13, 2024
@DellaBitta DellaBitta self-assigned this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants