@@ -62,6 +62,34 @@ function registerAdditionalInstrumentations(additionalInstrumentationModules) {
6262 * @param {import('./config').InstanaConfig } preliminaryConfig
6363 */
6464function preInit ( preliminaryConfig ) {
65+ // Check for unsupported ESM loader configurations and exit early
66+ if ( util . esm . hasExperimentalLoaderFlag ( ) ) {
67+ // eslint-disable-next-line no-console
68+ console . error (
69+ 'Node.js introduced breaking changes in versions 18.19.0 and above, leading to the discontinuation of support ' +
70+ `for the --experimental-loader flag by Instana. The current Node.js version is ${ process . version } and ` +
71+ 'this process will not be monitored by Instana. ' +
72+ "To ensure tracing by Instana, please use the '--import' flag instead. For more information, " +
73+ 'refer to the Instana documentation: ' +
74+ 'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.'
75+ ) ;
76+ return ; // Exit early - no-op
77+ }
78+
79+ // This loader worked with '--experimental-loader' in Node.js versions below 18.19.
80+ // TODO: Remove 'esm-loader.mjs' file and this log in the next major release (v6).
81+ if ( util . esm . hasEsmLoaderFile ( ) ) {
82+ // eslint-disable-next-line no-console
83+ console . error (
84+ "Detected use of 'esm-loader.mjs'. This file is no longer supported and will be removed in next major release. " +
85+ 'This process will not be monitored by Instana. ' +
86+ "To ensure tracing by Instana, please use the 'esm-register.mjs' file instead. For more information, " +
87+ 'refer to the Instana documentation: ' +
88+ 'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.'
89+ ) ;
90+ return ; // Exit early - no-op
91+ }
92+
6593 util . init ( preliminaryConfig ) ;
6694 util . hasThePackageBeenInitializedTooLate . activate ( ) ;
6795 tracing . preInit ( preliminaryConfig ) ;
@@ -77,6 +105,34 @@ function preInit(preliminaryConfig) {
77105 * @param {import('../../collector/src/pidStore') } processIdentityProvider
78106 */
79107function init ( config , downstreamConnection , processIdentityProvider ) {
108+ // Check for unsupported ESM loader configurations and exit early
109+ if ( util . esm . hasExperimentalLoaderFlag ( ) ) {
110+ // eslint-disable-next-line no-console
111+ console . error (
112+ 'Node.js introduced breaking changes in versions 18.19.0 and above, leading to the discontinuation of support ' +
113+ `for the --experimental-loader flag by Instana. The current Node.js version is ${ process . version } and ` +
114+ 'this process will not be monitored by Instana. ' +
115+ "To ensure tracing by Instana, please use the '--import' flag instead. For more information, " +
116+ 'refer to the Instana documentation: ' +
117+ 'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.'
118+ ) ;
119+ return ; // Exit early - no-op
120+ }
121+
122+ // This loader worked with '--experimental-loader' in Node.js versions below 18.19.
123+ // TODO: Remove 'esm-loader.mjs' file and this log in the next major release (v6).
124+ if ( util . esm . hasEsmLoaderFile ( ) ) {
125+ // eslint-disable-next-line no-console
126+ console . error (
127+ "Detected use of 'esm-loader.mjs'. This file is no longer supported and will be removed in next major release. " +
128+ 'This process will not be monitored by Instana. ' +
129+ "To ensure tracing by Instana, please use the 'esm-register.mjs' file instead. For more information, " +
130+ 'refer to the Instana documentation: ' +
131+ 'https://www.ibm.com/docs/en/instana-observability/current?topic=nodejs-collector-installation.'
132+ ) ;
133+ return ; // Exit early - no-op
134+ }
135+
80136 util . init ( config ) ;
81137 util . hasThePackageBeenInitializedTooLate . activate ( ) ;
82138 secrets . init ( config ) ;
0 commit comments