Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removed recursive-copy module from the production dependency #1265

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 68 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/shared-metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@
"@instana/core": "3.15.0",
"detect-libc": "^2.0.2",
"event-loop-lag": "^1.4.0",
"recursive-copy": "^2.0.13",
"fs-extra": "^11.2.0",
kirrg001 marked this conversation as resolved.
Show resolved Hide resolved
"semver": "^7.5.4",
"tar": "^6.2.1"
},
"devDependencies": {
"@types/fs-extra": "^11.0.4",
"@types/tar": "^6.1.6"
},
"optionalDependencies": {
Expand Down
33 changes: 14 additions & 19 deletions packages/shared-metrics/src/util/nativeModuleRetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const { logger: Logger, uninstrumentedFs: fs } = require('@instana/core');
let logger = Logger.getLogger('shared-metrics/native-module-retry');

const EventEmitter = require('events');
const copy = require('recursive-copy');
const os = require('os');
const tar = require('tar');
const path = require('path');
const detectLibc = require('detect-libc');
const fse = require('fs-extra');

/**
* @typedef {Object} InstanaSharedMetricsOptions
Expand Down Expand Up @@ -183,23 +183,14 @@ function copyPrecompiled(opts, loaderEmitter, callback) {
.then(() => {
// See below for the reason why we append 'precompiled' to the path.
const targetDir = path.join(opts.nativeModulePath, 'precompiled');
const sourceDir = path.join(os.tmpdir(), opts.nativeModuleName);
logger.debug(
`Copying the precompiled build for ${opts.nativeModuleName} ${label} from ${sourceDir} to ${targetDir}.`
);

// @ts-ignore
copy(
path.join(os.tmpdir(), opts.nativeModuleName),
targetDir,
{
overwrite: true,
dot: true
},
// @ts-ignore
cpErr => {
if (cpErr) {
logger.warn(`Copying the precompiled build for ${opts.nativeModuleName} ${label} failed.`, cpErr);
callback(false);
return;
}

fse
kirrg001 marked this conversation as resolved.
Show resolved Hide resolved
.copy(sourceDir, targetDir)
.then(() => {
// We have unpacked and copied the correct precompiled native addon. The next attempt to require the
// dependency should work.
//
Expand All @@ -211,10 +202,14 @@ function copyPrecompiled(opts, loaderEmitter, callback) {
// it will remember and not try to load anything from that path again (a `false` will be
// put into the cache for that cache key). Instead, we force a new path, by adding precompiled
// to the module path and use the absolute path to the module to load it.
logger.debug(`Successfully copied the precompiled build for ${opts.nativeModuleName} ${label}.`);
aryamohanan marked this conversation as resolved.
Show resolved Hide resolved
opts.loadFrom = targetDir;
callback(true);
}
);
})
.catch(error => {
logger.warn(`Copying the precompiled build for ${opts.nativeModuleName} ${label} failed.`, error);
callback(false);
});
})
.catch(tarErr => {
logger.warn(`Unpacking the precompiled build for ${opts.nativeModuleName} ${label} failed.`, tarErr);
Expand Down