Closed Rafal1 closed 2 years ago
Here is an app:
Maybe I can add a customizable filter. More precisely, I could call a user-defined function that filters the error message before logging. So you can decide yourself which error messages to show. Or you could even send the messages to the server instead of logging them on the client (inspired by https://github.com/log4js-node/logstashHTTP and similar frameworks).
Those initialization problems seem to be hard to solve directly (maybe we got any idea in the future) so suggested error managing mechanism would be a nice tool to see how often they occur for end users, maybe we even log something new.
I haven't checked it yet - but I've improved ngDestroy()
after realizing the close()
method of pdf.js is asynchronous. Maybe this already helps.
I've checked only a basic case on a current 10.0.0-alpha.8
version. Error No 2 from the list still occurs.
ERROR Error: Uncaught (in promise): Error: Transport destroyed
Does that mean the other errors are gone? That'd be great news!
Implementing a message filter is still on my ship list for version 10. Fun fact: I already had an implementation, but I threw it away because it wouldn't work. After several days, I learned that the new version of ng-packagr is broken. My implementation was probably OK :(
The filter has landed with version 11.0.0-alpha.4:
Window['ngxConsoleFilter'] = (level: string, message: any): boolean => {
return true;
}
export class NgxConsole {
public log(message: any): void {
if (Window['ngxConsoleFilter']('log', message)) {
console.log(message);
}
}
public error(message: any): void {
if (Window['ngxConsoleFilter']('error', message)) {
console.error(message);
}
}
public warn(message: any): void {
if (Window['ngxConsoleFilter']('warn', message)) {
console.warn(message);
}
}
}
Window['ngxConsole'] = new NgxConsole();
I've added the documentation of the feature to the showcase project.
Version of ngx-extended-pdf-viewer: 9.0.2 Browser: Firefox 89.0
I have a following structre in my code (all empty params are filled but not necessary here):
file-view.component.html
main-screen.component.html
If I enter to
main-screen
and right after that (ngx-extended-pdf-viewer is during the initialization, it is loading my pdf) I click back to the previous site in the browser. I got following errors (not at every try!). Everything works fine if I wait a bit longer but I don't want my users could see those errors in console.I've prepared a simple app to reproduce the issues (I couldn't make a stackblitz/codesandbox exmple cause https://github.com/stephanrauh/ngx-extended-pdf-viewer/issues/68). You will be able to reproduce 3 of 4 errors. The last one occurs in my app but it requires nested components which I was unable to reproduce in my example app :( but it's also related with delayed initialization.
1) unproduceable in example app:
2)
3)
4)