Skip to content

Commit

Permalink
feat: handle null targetServiceAppData (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
rentallect authored Oct 21, 2024
1 parent 3474025 commit 0abd17b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/context/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,8 @@ class ZitiContext extends EventEmitter {
this.targetService = options.target;
this.targetServiceAppData = await this.getConnectAppDataByServiceName (this.targetService.service, this.targetService.scheme);
this.targetServiceHost = await this.getConfigHostByServiceName (this.targetService.service);
if (isUndefined(this.targetServiceAppData)) {
this.targetServiceHostAndPort = `n/a`;
} else {
this.targetServiceHostAndPort = undefined;
if (!isUndefined(this.targetServiceAppData)) {
this.targetServiceHostAndPort = `${this.targetServiceAppData.dst_hostname}:${this.targetServiceAppData.dst_port}`;
}
this.bootstrapperHost = options.bootstrapperHost;
Expand Down
10 changes: 6 additions & 4 deletions src/http/readable-stream/_stream_passthrough.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ class PassThrough extends Transform {
* which leads to errors in Orion web UI.
*/
if (!isUndefined(chunk)) {
let decodedChunk = new TextDecoder().decode(chunk);
if (decodedChunk.indexOf(this.zitiContext.targetServiceHostAndPort) != -1) {
decodedChunk = decodedChunk.replaceAll(this.zitiContext.targetServiceHostAndPort, this.zitiContext.bootstrapperHost);
chunk = new TextEncoder().encode(decodedChunk);
if (!isUndefined(this.zitiContext.targetServiceHostAndPort)) { // if we have a targetServiceHostAndPort
let decodedChunk = new TextDecoder().decode(chunk);
if (decodedChunk.indexOf(this.zitiContext.targetServiceHostAndPort) != -1) {
decodedChunk = decodedChunk.replaceAll(this.zitiContext.targetServiceHostAndPort, this.zitiContext.bootstrapperHost);
chunk = new TextEncoder().encode(decodedChunk);
}
}
}
}
Expand Down

0 comments on commit 0abd17b

Please sign in to comment.