Open a-shpota opened 2 years ago
Does Zone.js just replace the globals or monkey-patch the Node.js modules as well? I mean: could we just add
const {setTimeout, setInterval} = require('timers');
at the beginning?
yes, timers monky-patched by zone.js, and needed for working ChangeDetection mechanism of angular.
It seems that it just works with .unref()
so no changes should be required?
import 'zone.js';
Zone.current.run(() => {
setTimeout(() => {
console.log('foobar');
}, 1000).unref();
});
// Uncomment this and foobar will be logged:
// setTimeout(() => {}, 1100);
I just tested
import 'zone.js';
import CacheableLookup from 'cacheable-lookup';
const cacheable = new CacheableLookup();
Zone.current.run(() => {
cacheable.lookup('google.com', console.log);
});
and it exists right away. Are you sure it is cacheable-lookup
that is keeping the zone busy?
i prepare repo for reproducing case and hope you can help me find the right solution
https://github.com/a-shpota/cacheable-reproduce
npm ci && npm run build:ssr && npm run serve:ssr
and try render page with request curl -v "http://localhost:4000"
in console print pending makrotasks with trace
entrypoint server.ts
I got
npm ERR! code ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! errno ENOTFOUND
npm ERR! network request to http://registry.rozetka.company/repository/npm-rzk-proxy/yargs-parser/-/yargs-parser-13.1.2.tgz failed, reason: getaddrinfo ENOTFOUND registry.rozetka.company
when running npm ci
, is this expected?
no, sorry. We used cacheable proxy. Fixes pushed
Problem: Has problem on use package with Zone.js of angular universal. Server (SSR) don`t render page while there are active ones zone.js macrotask.
Removed using setInterval & setTimeout