Feature: Enhance server CLI argument error handling and strict exit codes in server.main.ts
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Summary
Enhance the `errorReporter` in `src/vs/server/node/server.main.ts` to implement strict exit code handling and improved logging for server CLI arguments.
### Problem
Currently, `errorReporter` in `server.main.ts` logs issues like duplicate or empty CLI parameters to `console.error` / `console.warn` without stopping server execution. In headless or remote server environments, proceeding with invalid or conflicting arguments can lead to silent misconfigurations or unexpected runtime behavior.
### Proposed Solution
1. Introduce explicit `process.exit()` calls with dedicated exit codes for critical configuration errors (e.g., exit code `1` for duplicate arguments, `2` for empty arguments).
2. Enhance error message formatting to clearly distinguish between security/configuration errors and deprecation warnings.
### Code Example
```typescript
const errorReporter: ErrorReporter = {
onMultipleValues: (id: string, usedValue: string) => {
console.error(`[Security/Config Error] Option '${id}' can only be defined once. Using value ${usedValue}.`);
process.exit(1);
},
onEmptyValue: (id) => {
console.error(`[Security/Config Error] Option '${id}': Value must not be empty.`);
process.exit(2);
},
onUnknownOption: (id: string) => {
console.warn(`[Config Warning] Option '${id}': not supported for server.`);
},
onDeprecatedOption: (deprecatedOption: string, message) => {
console.warn(`[Deprecation Notice] Option '${deprecatedOption}' is deprecated: ${message}`);
}
};
Contributor guide
Assessment
This issue has not been assessed yet.