Skip to content

Commit

Permalink
fix: install Git in Ubuntu image
Browse files Browse the repository at this point in the history
Also remove retry attempts as I'm not 100% confident they'll work in every situation.
  • Loading branch information
ipsi committed Nov 9, 2022
1 parent 29ebf2a commit c90a22f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
2 changes: 1 addition & 1 deletion dockerfiles/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FROM ubuntu:20.04

RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node \
&& apt update && apt upgrade -y && apt install gpg curl xz-utils -y
&& apt update && apt upgrade -y && apt install git gpg curl xz-utils -y

ENV NODE_VERSION 16.17.0

Expand Down
27 changes: 3 additions & 24 deletions lib/stream-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ class ResponseStreamer {

#buffer;

#requestCount = 0;

constructor(logContext, config, brokerToken, streamingID) {
this.#logContext = logContext;
this.#config = config;
this.#brokerToken = brokerToken;
this.#streamingID = streamingID;
}

initStream(ioData, retryCallback) {
initStream(ioData) {
this.#buffer = new stream.PassThrough({ highWaterMark: 1048576 });
const postRequest = request({
url: `${this.#config.brokerServerUrl}/response-data/${
Expand All @@ -41,22 +39,6 @@ class ResponseStreamer {
postRequest
.on('error', (e) => {
logger.error({ error: e }, 'received error sending data via POST');
if (
e.message.includes('connect ETIMEDOUT') &&
retryCallback &&
this.#requestCount < MAX_ATTEMPTS
) {
logger.error(
{
...this.#logContext,
requestCount: this.#requestCount,
MAX_ATTEMPTS,
},
'connect timed out - making another POST request to the server',
);
this.#requestCount++;
retryCallback();
}
})
.on('response', (r) => {
if (r.statusCode !== 200) {
Expand Down Expand Up @@ -92,9 +74,7 @@ class ResponseStreamer {
{ ...this.#logContext, statusAndHeaders, body },
"posting internal response back to Broker Server as it's expecting streaming response",
);
this.initStream(JSON.stringify(statusAndHeaders), () =>
this.sendData(statusAndHeaders, body),
);
this.initStream(JSON.stringify(statusAndHeaders));
this.#buffer.write(typeof body !== 'string' ? JSON.stringify(body) : body);
this.#buffer.end();
}
Expand All @@ -118,7 +98,6 @@ class ResponseStreamer {
'Content-Type': 'application/json',
},
}),
doSend,
);
this.#buffer.write(body);
this.#buffer.end();
Expand All @@ -139,7 +118,7 @@ class ResponseStreamer {
status,
headers: response.headers,
});
this.initStream(ioData, () => this.pipeStream(rqst));
this.initStream(ioData);
})
.on('data', (chunk) => {
logger.trace(`writing data of length ${chunk.length} to buffer`);
Expand Down

0 comments on commit c90a22f

Please sign in to comment.