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.

Unable to run angular universal app with firebase hosting due to zone error

See original GitHub issue

Bug Report

What is the expected behavior?

The app should run and not give

What is the current behavior?

The below error is coming up

 '   Unhandled Promise rejection: factory is not a function ; Zone: <root> ; Task: Promise.then ; Value: TypeError: factory is not a function     at _callFactory (/user_code/node_modules/@angular/core/bundles/core.umd.js:19854:24)     at _createProviderInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:19810:30)     at resolveNgModuleDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:19771:25)     at NgModuleRef_.get (/user_code/node_modules/@angular/core/bundles/core.umd.js:20479:20)     at resolveDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:20850:49)     at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:20730:36)     at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:20601:24)     at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21827:40)     at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22143:17)     at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22062:17)     at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21855:9)     at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22143:17)     at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22062:17)     at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21855:9)     at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:21741:9)     at Object.createProdRootView [as createRootView] (/user_code/node_modules/@angular/core/bundles/core.umd.js:22253:16)     at ComponentFactory_.create (/user_code/node_modules/@angular/core/bundles/core.umd.js:20080:33)     at ComponentFactoryBoundToModule.create (/user_code/node_modules/@angular/core/bundles/core.umd.js:9762:33)     at ApplicationRef.bootstrap (/user_code/node_modules/@angular/core/bundles/core.umd.js:16887:44)     at /user_code/node_modules/@angular/core/bundles/core.umd.js:16695:85     at Array.forEach (native)     at PlatformRef._moduleDoBootstrap (/user_code/node_modules/@angular/core/bundles/core.umd.js:16695:48) TypeError: factory is not a function     at _callFactory (/user_code/node_modules/@angular/core/bundles/core.umd.js:19854:24)     at _createProviderInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:19810:30)     at resolveNgModuleDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:19771:25)     at NgModuleRef_.get (/user_code/node_modules/@angular/core/bundles/core.umd.js:20479:20)     at resolveDep (/user_code/node_modules/@angular/core/bundles/core.umd.js:20850:49)     at createClass (/user_code/node_modules/@angular/core/bundles/core.umd.js:20730:36)     at createDirectiveInstance (/user_code/node_modules/@angular/core/bundles/core.umd.js:20601:24)     at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21827:40)     at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22143:17)     at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22062:17)     at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21855:9)     at callViewAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22143:17)     at execComponentViewsAction (/user_code/node_modules/@angular/core/bundles/core.umd.js:22062:17)     at createViewNodes (/user_code/node_modules/@angular/core/bundles/core.umd.js:21855:9)     at createRootView (/user_code/node_modules/@angular/core/bundles/core.umd.js:21741:9)     at Object.createProdRootView [as createRootView] (/user_code/node_modules/@angular/core/bundles/core.umd.js:22253:16)     at ComponentFactory_.create (/user_code/node_modules/@angular/core/bundles/core.umd.js:20080:33)     at ComponentFactoryBoundToModule.create (/user_code/node_modules/@angular/core/bundles/core.umd.js:9762:33)     at ApplicationRef.bootstrap (/user_code/node_modules/@angular/core/bundles/core.umd.js:16887:44)     at /user_code/node_modules/@angular/core/bundles/core.umd.js:16695:85     at Array.forEach (native)     at PlatformRef._moduleDoBootstrap (/user_code/node_modules/@angular/core/bundles/core.umd.js:16695:48) | more_vert  '  + 
 '  -- | --  ' ; 

What modules are related to this issue?

Not much idea about it but from logs it looks like Zone or @angular/core

Minimal reproduction with instructions:

I am running this code on firebase cloud functions

import 'zone.js/dist/zone-node';
import 'reflect-metadata';


const express = require('express');
const path = require('path');
const { enableProdMode } = require('@angular/core');
const { renderModuleFactory } = require('@angular/platform-server');

const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('../dist/server/main');
const { provideModuleMap } = require('@nguniversal/module-map-ngfactory-loader');
enableProdMode();

const index = require('fs')
  .readFileSync(path.resolve(__dirname, '../dist/browser/index.html'), 'utf8')
  .toString();

let app = express();

app.get('**', function(req, res) {
  renderModuleFactory(AppServerModuleNgFactory, {
    url: req.path,
    document: index,
    extraProviders: [
      provideModuleMap(LAZY_MODULE_MAP)
    ]
  }).then(html => res.status(200).send(html));
});

exports.workernApp = functions.https.onRequest(app);

What is the use-case or motivation for changing an existing behavior?

Successful running website

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
davidstellinicommented, Dec 29, 2018

I solved it. Sorry I’m on my phone but you can follow the tutorial for angular firebase 2. I uploaded an example to my github.

On Sat, 29 Dec 2018, 15:34 kartik2206 <notifications@github.com wrote:

No I moved on(Didn’t used universal app) and didn’t tried much after that to solve the issue. Do let me know if you solve the issue.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/universal/issues/1095#issuecomment-450493659, or mute the thread https://github.com/notifications/unsubscribe-auth/AEH8Q3z0YgkSwsnTGRiHJdddMyKV-BMPks5u9298gaJpZM4YxlVC .

0reactions
maxisamcommented, May 3, 2021

I have this issue as well. I am not even use firebase.

Unhandled Promise rejection: not ready ; Zone: <root> ; Task: Server.addListener:request ; Value: Error: not ready at /web/dist/server/main.js:1:2131786 at check (/web/dist/server/main.js:1:4033630) at Server.<anonymous> (/web/dist/server/main.js:1:4034264) at ZoneDelegate.invokeTask (/web/dist/server/main.js:1:4368987) at Zone.runTask (/web/dist/server/main.js:1:4361552) at ZoneTask.invokeTask (/web/dist/server/main.js:1:4370572) at Server.ZoneTask.options.useG.invoke (/web/dist/server/main.js:1:4370401)

I feel like somewhere there is a promise not being handled.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error while serving angular universal locally in firebase
(see above) - It appears your code is written in Typescript, which must be compiled before emulation. - You may be able to...
Read more >
Why Angular Universal Server Side Rendering get an error ...
I had a similar issue to you and was able to resolve it by moving my server.js file from the DIST folder into...
Read more >
Integrate Angular Universal | Firebase Hosting - Google
Initialize a new project · In the Firebase CLI, enable the web frameworks preview: · Run the initialization command from the CLI and...
Read more >
angular/fire - npm
Start using @angular/fire in your project by running `npm i ... Get your Angular application deployed on Firebase Hosting with a single ...
Read more >
Angular Universal & Firebase functions: The missing guide
Check this step-by-step guide to configure Angular Universal in your current project, and learn how to run Universal from Firebase!
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