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

Error: NotYetImplemented at Document2.exports2.nyi #6677

Closed
Santoshah opened this issue Oct 11, 2022 · 13 comments · Fixed by #6686
Closed

Error: NotYetImplemented at Document2.exports2.nyi #6677

Santoshah opened this issue Oct 11, 2022 · 13 comments · Fixed by #6686

Comments

@Santoshah
Copy link

    The warning shouldn't affect any code functionality but you can downgrade to 9.10.0 if you want to avoid having a warning (or if I'm wrong and it is affecting your code). I have a fix (https://github.com/firebase/firebase-js-sdk/pull/6665) which should be released next week.

Originally posted by @hsubox76 in #6660 (comment)

@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@Santoshah
Copy link
Author

Santoshah commented Oct 11, 2022

This does affect build of SSR version.

Also due to this my codepipeline broke at deploying stage. Upgrading my package from 9.8.1 to 9.10.0 does fixed the issue.

If updated to latest version 9.11.0 its again a issue.

image

@hsubox76
Copy link
Contributor

Thanks for the info, we'll be releasing a fix today or if not today, tomorrow.

@hsubox76
Copy link
Contributor

The fix has been released in 9.12.0.

@Santoshah
Copy link
Author

Santoshah commented Oct 12, 2022

The warning message is fixed but still SSR is not working.

image


.children||(module2.children=[]),module2),__webpack_require__.p="",installedChunks={179:1},installChunk=__name(chunk=>{var moreModules=chunk.modules,chunkIds=chunk.ids,runtime=chunk.runtime;for(var moduleId in moreModules)__webpack_require__.o(moreModules,moduleId)&&(__webpack_require__.m[moduleId]=moreModules[moduleId]);runtime&&runtime(__webpack_require__);for(var i2=0;i2<chunkIds.length;i2++)installedChunks[chunkIds[i2]]=1},"installChunk"),__webpack_require__.f.require=(chunkId,promises)=>{installedChunks[chunkId]||installChunk(require("./"+__webpack_require__.u(chunkId)))};var __webpack_exports__=__webpack_require__(23038),__webpack_export_target__=exports;for(var i in __webpack_exports__)__webpack_export_target__[i]=__webpack_exports__[i];__webpack_exports__.__esModule&&Object.defineProperty(__webpack_export_target__,"__esModule",{value:!0})})();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

Error: NotYetImplemented
    at Document2.exports2.nyi (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:11633309)
    at getDefaultsFromCookie (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:727451)
    at getDefaults (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:727690)
    at Object.getDefaultEmulatorHost (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:727821)
    at getFunctions (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:661359)
    at Object.36747 (/Users/santoshshah/projects/cloneProject/projectname/server/main.js:1:1296600)
    at __webpack_require__ (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:18589422)
    at Object.28061 (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:1298389)
    at __webpack_require__ (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:18589422)
    at Object.81789 (/Users/santoshshah/projects/cloneProject/dist/projectname/server/main.js:1:10168300)


The build is success but while trying to serve it get this error.

This suddenly happen with firebase 9.8.1 in our running project while deploying to live via codepipeline. If there is a fresh npm install then it will throw that error. In our local we have old node_modules that is why its working. However after upgrading to 9.10.0 it is fixed. But tested with 9.11.0 and 9.12.0 still not wokring.

@Santoshah Santoshah changed the title The warning shouldn't affect any code functionality but you can downgrade to 9.10.0 if you want to avoid having a warning (or if I'm wrong and it is affecting your code). I have a fix (https://github.com/firebase/firebase-js-sdk/pull/6665) which should be released next week. Oct 12, 2022
@hsubox76 hsubox76 reopened this Oct 12, 2022
@hsubox76
Copy link
Contributor

I don't think it's possible that you could get the same error in 9.8.1 because this method wasn't introduced until 9.11.0, possibly there was something left over in the node_modules or package-lock.json or yarn.lock.

Anyway it seems the problem is in

const match = document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/);

Your SSR environment has a document object but it doesn't have a document.cookie or errors when you try to call it. Based on the error it looks like you're using Angular Universal, let me know if that's not the case. I'll do some research into the behavior of the document object in Angular Universal and see if I can figure it out. Also if this is a catchable error I'll look into wrapping the entire getDefaults function in a try/catch so that whatever odd environment errors happen, it won't block the rest of the app.

@Santoshah
Copy link
Author

Santoshah commented Oct 12, 2022

Yes, its an Angular Universal project.

I first notice this on Oct 10. while the code was uploding via aws codepipeline. This happens very sudden because before that my code was running fine. My firebase version was 9.8.1. (dam sure.) My deployment was success but the site throws 502 error. I login to server and checked that no command was running. Then I manually run the command npm run serve:ssr but it throws the same error Error NotYetImplemented. Then I checked the logs where I could see the same warning message after build was made.
image

I tried to search that in internet and thats how I came to this post.

This error appears on 9.8.1 only when fresh npm install is made. Like codepipeline does with codebuild. My local project build worked fine. I tried to clone my project and checked with fresh npm install and I received the error.

I saw comments where user says that its working fine with firebase 9.10.0 That's how I upgrade the firebase and checked and it was working fine. But when I update to 9.11.0 it throws same error. And again with 9.12.0 still not fixed..


I just change to 9.8.1 again to see if the error exist. I cloned my project.
Deleted node_modules folder
Deleted package json lock file
delete cache folder.
run npm install
run npm run build:prod:ssr
then run npm run serve:ssr

I see this error. In screenshot you can see my firebase version is 9.8.1

image

My server.ts code.

import { enableProdMode } from "@angular/core";
(global as any).WebSocket = require('ws');
(global as any).XMLHttpRequest = require('xhr2');
import 'zone.js/dist/zone-node';
const domino = require('domino');
const fs = require('fs');
const path = require('path');

import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
import { existsSync } from 'fs';
const dotenv = require('dotenv');
dotenv.config();
const distFolder = join(process.cwd(), 'dist/projectname/browser');
const template = fs.readFileSync(path.join(distFolder, 'index.html')).toString();
const win = domino.createWindow(template.toString());
global['window'] = win;
global['document'] = win.document;
global['DOMTokenList'] = win.DOMTokenList;
global['Node'] = win.Node;
global['Text'] = win.Text;
global['HTMLElement'] = win.HTMLElement;
global['navigator'] = win.navigator;
global['getComputedStyle'] = win.getComputedStyle;

(global as any).self = {fetch: require('node-fetch')};

// Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode();

import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';


// The Express app is exported so that it can be used by serverless Functions.
export function app(): express.Express {
  const server = express();
  const distFolder = join(process.cwd(), 'dist/projectname/browser');
  const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index';

  server.engine('html',  (_, options : any, callback) => {
    let engine = ngExpressEngine({
      bootstrap: AppServerModule,
      providers: [ { provide: 'host', useFactory: () => options.req.get('host') } ]
    });
  
    engine(_, options, callback)
  })
  server.set('view engine', 'html');
  server.set('views', distFolder);


  server.get('*.*', express.static(distFolder, {
    maxAge: '1y'
  }));
  let routesPath = ['/invite', '/invite/**','/lm', '/dashboard', '/dashboard/**', '/public/**', '/public', '/pre'];
  server.get(routesPath, (req, res) => {
    res.sendFile(distFolder + '/index.html');
  });

  // All regular routes use the Universal engine
  server.get('*', (req, res) => {    
      res.render(indexHtml, { req, providers: [
        { provide: APP_BASE_HREF, useValue: req.baseUrl }, 
        { provide: 'customConfig', useValue: req.get('host') }
      ] 
  });




  });

  return server;
}

function run(): void {
  const port = process.env.PORT || 8000;
  // Start up the Node server
  const server = app();
  server.get('/env', (req, res) => {
    res.json(process.env);
  })
  server.listen(port, () => {
    console.log(`Node Express server listening on https://localhost:${port}`);
  });
}

declare const __non_webpack_require__: NodeRequire;
const mainModule = __non_webpack_require__.main;
const moduleFilename = mainModule && mainModule.filename || '';
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) {
  run();
}

export * from './src/main.server';

@hsubox76
Copy link
Contributor

In your package.json you don't have it pinned to 9.8.1, you have a ^ which is asking it to grab the latest version above 9.8.1, as long as it isn't a major bump (as long as it's not 10.x.x or above). So when you do a fresh npm install, it won't grab 9.8.1, it will grab the latest version. If it's important to install the exact version I would suggest you remove the ^. https://nodesource.com/blog/semver-tilde-and-caret/

In any case I'm working on a fix to be released in the next version, likely 9.12.1.

@Santoshah
Copy link
Author

Thanks for the comments. I want to keep my code up to date. Thank for the ^ tips.

@Santoshah
Copy link
Author

With 9.12.1 build working fine. Thanks for the quick realease.

@shreyasPL
Copy link

Hey,
This issue of @firebase/util FIREBASE_DEFAULTS , is expected still persists,
I did the following before running the app,
Our app is ionic capacitor app.


Latest Dependencies:

  @capacitor/cli: 4.3.0
  @capacitor/core: 4.3.0
  @capacitor/android: 4.3.0
  @capacitor/ios: 4.3.0

Installed Dependencies:

  @capacitor/cli: 4.3.0
  @capacitor/core: 4.3.0
  @capacitor/android: 4.3.0
  @capacitor/ios: 4.3.0

[success] iOS looking great! 👌
[success] Android looking great! 👌 
  1. deleted node_modules
  2. deleted package_lock.json
  3. Updated firebase: 9.12.1 in package.json
  4. Installed packages again.

Please share some insight.
We are facing issue in the following as we are trying to refreshToken forcefully after an hour, by storing the txp in localStorage.
getIdToken(true) also returns -> jsonexception with
auth/network-request-failed as error.
getIdToken() without the forceRefreshToken as param is working fine, until the token becomes expired, that's when, there is no response, but the error.
Thank you.

@hsubox76
Copy link
Contributor

I'm not sure if I'm reading your comment correctly but it sounds like you have two separate issues:

(1) Something about FIREBASE_DEFAULTS. Is it the exact error above ("NotYetImplemented at Document2.exports2.nyi") or something else? If it's something else, can you create a new issue and add more details about what the exact error is?

(2) Something to do with auth and refreshToken. Can you create a separate issue for this and provide the code you are using to call these auth methods?

@shreyasPL
Copy link

yes I do have two separate issues, Will create two separate tickets.
Thank you.

@firebase firebase locked and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
5 participants