mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Replace spawn with execFile for memory-safe command execution (#1068)
This commit is contained in:
@@ -447,7 +447,11 @@ describe('loggers', () => {
|
||||
});
|
||||
|
||||
it('should log ripgrep fallback event', () => {
|
||||
const event = new RipgrepFallbackEvent();
|
||||
const event = new RipgrepFallbackEvent(
|
||||
false,
|
||||
false,
|
||||
'ripgrep is not available',
|
||||
);
|
||||
|
||||
logRipgrepFallback(mockConfig, event);
|
||||
|
||||
@@ -460,13 +464,13 @@ describe('loggers', () => {
|
||||
'session.id': 'test-session-id',
|
||||
'user.email': 'test-user@example.com',
|
||||
'event.name': EVENT_RIPGREP_FALLBACK,
|
||||
error: undefined,
|
||||
error: 'ripgrep is not available',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('should log ripgrep fallback event with an error', () => {
|
||||
const event = new RipgrepFallbackEvent('rg not found');
|
||||
const event = new RipgrepFallbackEvent(false, false, 'rg not found');
|
||||
|
||||
logRipgrepFallback(mockConfig, event);
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ export function logRipgrepFallback(
|
||||
config: Config,
|
||||
event: RipgrepFallbackEvent,
|
||||
): void {
|
||||
QwenLogger.getInstance(config)?.logRipgrepFallbackEvent();
|
||||
QwenLogger.getInstance(config)?.logRipgrepFallbackEvent(event);
|
||||
if (!isTelemetrySdkInitialized()) return;
|
||||
|
||||
const attributes: LogAttributes = {
|
||||
|
||||
@@ -38,6 +38,7 @@ import type {
|
||||
ModelSlashCommandEvent,
|
||||
ExtensionDisableEvent,
|
||||
AuthEvent,
|
||||
RipgrepFallbackEvent,
|
||||
} from '../types.js';
|
||||
import { EndSessionEvent } from '../types.js';
|
||||
import type {
|
||||
@@ -778,8 +779,16 @@ export class QwenLogger {
|
||||
this.flushIfNeeded();
|
||||
}
|
||||
|
||||
logRipgrepFallbackEvent(): void {
|
||||
const rumEvent = this.createActionEvent('misc', 'ripgrep_fallback', {});
|
||||
logRipgrepFallbackEvent(event: RipgrepFallbackEvent): void {
|
||||
const rumEvent = this.createActionEvent('misc', 'ripgrep_fallback', {
|
||||
snapshots: JSON.stringify({
|
||||
platform: process.platform,
|
||||
arch: process.arch,
|
||||
use_ripgrep: event.use_ripgrep,
|
||||
use_builtin_ripgrep: event.use_builtin_ripgrep,
|
||||
error: event.error ?? undefined,
|
||||
}),
|
||||
});
|
||||
|
||||
this.enqueueLogEvent(rumEvent);
|
||||
this.flushIfNeeded();
|
||||
|
||||
@@ -318,10 +318,20 @@ export class FlashFallbackEvent implements BaseTelemetryEvent {
|
||||
export class RipgrepFallbackEvent implements BaseTelemetryEvent {
|
||||
'event.name': 'ripgrep_fallback';
|
||||
'event.timestamp': string;
|
||||
use_ripgrep: boolean;
|
||||
use_builtin_ripgrep: boolean;
|
||||
error?: string;
|
||||
|
||||
constructor(public error?: string) {
|
||||
constructor(
|
||||
use_ripgrep: boolean,
|
||||
use_builtin_ripgrep: boolean,
|
||||
error?: string,
|
||||
) {
|
||||
this['event.name'] = 'ripgrep_fallback';
|
||||
this['event.timestamp'] = new Date().toISOString();
|
||||
this.use_ripgrep = use_ripgrep;
|
||||
this.use_builtin_ripgrep = use_builtin_ripgrep;
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user