Closed kashw2 closed 6 months ago
@kashw2 are you bundling your code with the applicationinsights SDK code?, the code always try to read the file, and by default it will read the applicationinsighs.json that is part of the actual npm package, I suppose this could be a problem if there is some bundling involved
Hi, yes I'm currently using esbuild to bundle. Something odd that I only just noticed when reproducing this issue again was that the location that it was requiring the applicationinsights.json file to be was actually not part of the application directory itself and was in the parent directory.
The project I work on is apart of a monorepo with the project in question having a layout like:
myProject
|
------ V1
|
------ V2
When reproducing this issue now, it actually asks for the applicationinsights.json file to be present in the myProject directory instead of the V2 directory that I am working on and building out of.
I'm actually experiencing the same issue. It's asking for the config file located outside my project directory. I have downgraded to version 2.7.3
and the error has disappeared.
I'm trying to isolate the changes that triggered the error and will update once I have found it.
Hi, yes I'm currently using esbuild to bundle. Something odd that I only just noticed when reproducing this issue again was that the location that it was requiring the applicationinsights.json file to be was actually not part of the application directory itself and was in the parent directory.
The project I work on is apart of a monorepo with the project in question having a layout like:
myProject | ------ V1 | ------ V2
When reproducing this issue now, it actually asks for the applicationinsights.json file to be present in the myProject directory instead of the V2 directory that I am working on and building out of.
Experiencing something similar - did you find a workaround? @kashw2
We have been able to overwrite using: process.env.APPLICATIONINSIGHTS_CONFIGURATION_CONTENT = '{}'
per docs:
Alternatively, instead of using a configuration file, you can specify the entire content of the JSON configuration via the APPLICATIONINSIGHTS_CONFIGURATION_CONTENT environment variable .
Just got a chance to check the solution from @jakereifer.
While this does remove the warning during build, the issue of telemetry data not being sent to Application Insights and viewable in the Live Metrics pane still persists. Is this also the case when you attempted this?
@kashw2 this still sends telem to app insights for me - we're also using @vscode/extension-telemetry
which depends on applicationinsights
. not sure if that changes anything
@kashw2 are you bundling your code with the applicationinsights SDK code?, the code always try to read the file, and by default it will read the applicationinsighs.json that is part of the actual npm package, I suppose this could be a problem if there is some bundling involved
@hectorhdzg: This is definitely a problem for us. We are also bundling the code (with esbuild) and unless we explicitly exclude applicationinsights
from bundling we get this error message.
And for us it also looks in a folder which is one level above from where our application is in. Maybe this could even be used as an attack vector, if a file is placed there, to divert the telemetry data to a different place.
How a file from the source code is dynamically loaded during runtime in https://github.com/microsoft/ApplicationInsights-node.js/blob/0217324c477a96b5dd659510bbccad27934084a3/Library/JsonConfig.ts#L129-L131 really looks like a bug to me. This could be fixed e.g. by instead requiring that file statically and using that instead. With this in place bundlers could also handle this correctly.
In #1241 and #1242 I have two proposed fixes for this. The first one being more minimal, the second one more elaborate.
Environment: OS: NixOS 23.05 (Linux) Node:
18.17.1
applicationinsights version:2.9.0
After upgrading the
applicationinsights
package in my project from2.7.3
to2.8.0
and then to2.9.0
when running my NodeJS application using theAPPLICATIONINSIGHTS_CONNECTION_STRING
variable as done prior to2.8.0
I get the warning:the warning is not present during build and goes away if i provide the
applicationinsights.json
however this functionality looks to be opt-in via theAPPLICATIONINSIGHTS_CONFIGURATION_FILE
variable which I've not set.When the application is running after the warning, the live metrics page doesnt load and reports no telemetry is being received, this works again as expected when downgrading to
2.7.3
.My application insights initialisation looks like the following: