Skip to content

Commit 6c8f1b9

Browse files
committed
fix: obfuscated exception message
before: ● Node host › can run a command from plugin failed request to "nvim_command" (see $NVIM_NODE_LOG_FILE for details, if it was set) 75 | request(name, args = []) { 76 | // Dummy error, to get stacktrace. > 77 | const error = new Error(`failed request to "${name}" (see $NVIM_NODE_LOG_FILE for details, if it was set)`); | ^ 78 | return this.asyncRequest(name, args, error.stack); 79 | } 80 | _getArgsByPrefix(...args) { at NeovimClient.request (../neovim/lib/api/Base.js:77:23) at NeovimClient.request (../neovim/lib/api/Neovim.js:355:21) at Object.command (__tests__/integration.test.ts:85:16) after: ● Node host › can run a command from plugin nvim_command: Vim:E492: Not an editor command: JSHostTestCmd 67 | return this[DO_REQUEST](name, args).catch(err => { 68 | // XXX: Get a `*.ts stacktrace. If we re-throw `err` we get a `*.js` trace. tsconfig issue? > 69 | const newError = new Error(err.message); | ^ 70 | this.logger.error(`failed request to "%s": %s: %s`, name, newError.name, newError.message); 71 | throw newError; 72 | }); at ../neovim/lib/api/Base.js:69:34 at Object.<anonymous> (__tests__/integration.test.ts:85:5)
1 parent a19148b commit 6c8f1b9

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

packages/neovim/src/api/Base.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class BaseApi extends EventEmitter {
7373
[DO_REQUEST] = (name: string, args: any[] = []): Promise<any> =>
7474
new Promise((resolve, reject) => {
7575
this.transport.request(name, args, (err: any, res: any) => {
76-
this.logger.debug(`response -> neovim.api.${name}: ${res}`);
76+
this.logger.debug(`response -> ${name}: ${res}`);
7777
if (err) {
7878
reject(new Error(`${name}: ${err[1]}`));
7979
} else {
@@ -85,19 +85,18 @@ export class BaseApi extends EventEmitter {
8585
async asyncRequest(
8686
name: string,
8787
args: any[] = [],
88-
stack: string | undefined = undefined
8988
): Promise<any> {
9089
// `this._isReady` is undefined in ExtType classes (i.e. Buffer, Window, Tabpage)
9190
// But this is just for Neovim API, since it's possible to call this method from Neovim class
9291
// before transport is ready.
9392
// Not possible for ExtType classes since they are only created after transport is ready
9493
await this._isReady;
9594

96-
this.logger.debug(`request -> neovim.api.${name}`);
95+
this.logger.debug(`request -> ${name}`);
9796

9897
return this[DO_REQUEST](name, args).catch(err => {
98+
// XXX: Get a `*.ts stacktrace. If we re-throw `err` we get a `*.js` trace. tsconfig issue?
9999
const newError = new Error(err.message);
100-
newError.stack = stack;
101100
this.logger.error(
102101
`failed request to "%s": %s: %s`,
103102
name,
@@ -109,12 +108,7 @@ export class BaseApi extends EventEmitter {
109108
}
110109

111110
request(name: string, args: any[] = []): Promise<any> {
112-
// Dummy error, to get stacktrace.
113-
const error = new Error(
114-
`failed request to "${name}" (see $NVIM_NODE_LOG_FILE for details, if it was set)`
115-
);
116-
117-
return this.asyncRequest(name, args, error.stack);
111+
return this.asyncRequest(name, args);
118112
}
119113

120114
_getArgsByPrefix(...args: any[]): any[] {
@@ -169,7 +163,7 @@ export class BaseApi extends EventEmitter {
169163
// TODO: Is this necessary?
170164
/** `request` is basically the same except you can choose to wait forpromise to be resolved */
171165
notify(name: string, args: any[]): void {
172-
this.logger.debug(`notify -> neovim.api.${name}`);
166+
this.logger.debug(`notify -> ${name}`);
173167
this.transport.notify(name, args);
174168
}
175169
}

0 commit comments

Comments
 (0)