Skip to content

Commit

Permalink
fix: prevent socket unlinking in worker threads (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
beliarh authored Oct 18, 2023
1 parent 85e2a92 commit c27fdd8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/expresskit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cluster from 'cluster';
import fs from 'fs';
import type {Server} from 'http';
import {isMainThread} from 'worker_threads';

import type {AppConfig, NodeKit} from '@gravity-ui/nodekit';
import express, {Express} from 'express';
Expand Down Expand Up @@ -42,6 +43,7 @@ export class ExpressKit {
appSocket &&
listenTarget === appSocket &&
cluster.isPrimary &&
isMainThread &&
fs.existsSync(appSocket)
) {
fs.unlinkSync(appSocket);
Expand Down

0 comments on commit c27fdd8

Please sign in to comment.