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.

Receiving "Zone already loaded" error when requiring AI client in Function App

See original GitHub issue

Using applicationinsights@1.0.0 I am receiving this error, which causes the function to fail and respond 500:

2017-10-25T14:58:03.588 Exception while executing function: Functions.di-session-update
2017-10-25T14:58:03.588 Error: Zone already loaded.
    at new Error (native)
    at D:\home\site\wwwroot\node_modules\zone.js\dist\zone-node.js:25:15 [<root>]
    at D:\home\site\wwwroot\node_modules\zone.js\dist\zone-node.js:971:3 [<root>]
    at Zone.Zone.zoneSpec._properties (D:\home\site\wwwroot\node_modules\zone.js\dist\zone-node.js:9:68)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\zone.js\dist\zone-node.js:12:2)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at Module.patchedRequire [as require] (D:\home\site\wwwroot\node_modules\diagnostic-channel\dist\src\patchRequire.js:14:46)
    at require (internal/module.js:20:19)
2017-10-25T14:58:03.588 Function completed (Failure, Id=9b458b5a-010e-4bbf-adaa-3616ea3de4b7, Duration=28ms)
2017-10-25T14:58:03.588 Executed 'Functions.di-session-update' (Failed, Id=9b458b5a-010e-4bbf-adaa-3616ea3de4b7)

This isn’t an issue for my other function which is part of the function app.

My functions currently share a package.json file between them, and I configure the ApplicationInsights client inside some shared library code, so I wonder if there’s something happening here which might cause the module to be included twice:

const appInsights = require('applicationinsights');
function setupInsights() {
    /* omitted dev-only code which skips setup if process.env.NODE_ENV is dev */
    appInsights.setup()
        .setAutoCollectConsole(true, true) // Enable logging of all console methods.
        .start();
    return appInsights;
}

module.exports = setupInsights();

I had a look in CorrelationContextManager.js to see where it’s being required, but I’m not doing anything too special.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
OsvaldoRosadocommented, Feb 22, 2018

This should be fixed now in 1.0.2. Please reopen if you’re still seeing this!

0reactions
willmorgancommented, Feb 22, 2018

@OsvaldoRosado Thanks - I’ll update and give it a go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

zone.js:25 Uncaught Error: Zone already loaded
This error occurs when you're trying to include zone.js script second time. – yurzui. Oct 20, 2016 at 20:03.
Read more >
Azure Application Insights for JavaScript web apps
This setting is used only for reporting SDK load failures. Reporting will first attempt to use fetch() if available and then fall back...
Read more >
Troubleshooting Cloud Functions - Google Cloud
This error message indicates that the caller does not have permission to invoke the function.
Read more >
Uncaught Error: Zone already loaded - Microsoft Q&A
Hello Everyone, I have created project in Angular and added in SharePoint page using Content Editor.
Read more >
Driving impact at scale from automation and AI - McKinsey
Artificial intelligence is getting ready for business, but are businesses ready for AI? ... applications requires large labeled training data.
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