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: ignore ENOENT error when cleaning logdir #90

Merged
merged 2 commits into from
Oct 26, 2020

Conversation

Claude-Ray
Copy link
Member

There is a race condition when multi processes are cleaning logdir.

Error: ENOENT: no such file or directory, unlink '/Users/claude/demo/logs/xprofiler-uds-path-17977.sock'
    at Object.unlinkSync (fs.js:1136:3)
    at /Users/claude/demo/node_modules/xprofiler/lib/clean.js:35:10
    at Array.forEach (<anonymous>)
    at clean (/Users/claude/demo/node_modules/xprofiler/lib/clean.js:33:13)
    at Function.start (/Users/claude/demo/node_modules/xprofiler/xprofiler.js:65:3)
    at Object.<anonymous> (/Users/claude/demo/index.js:10:11)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)

@codecov
Copy link

codecov bot commented Oct 26, 2020

Codecov Report

Merging #90 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #90   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          285       287    +2     
=========================================
+ Hits           285       287    +2     
Impacted Files Coverage Δ
lib/clean.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c82aa5...216fab6. Read the comment docs.

lib/clean.js Outdated
fs.unlinkSync(path.join(logdir, filename));
} catch (err) {
// ignore ENOENT error caused by race condition
if (err.code !== 'ENOENT') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean 并不是启动 xprofiler 的必须操作,这里可以只记录错误信息,但是不 throw

@hyj1991
Copy link
Member

hyj1991 commented Oct 26, 2020

感谢反馈,确实有这个问题,判断条件的 throw 可以改为记录即可 console.error

@Claude-Ray
Copy link
Member Author

了解,我修改一下

Copy link
Member

@hyj1991 hyj1991 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@hyj1991 hyj1991 merged commit fbfc601 into X-Profiler:master Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants