in src/RuntimeClient/RuntimeClient.ts [149:185]
async nextInvocation(): Promise<InvocationResponse> {
if (this.useAlternativeClient) {
const options = {
hostname: this.hostname,
port: this.port,
path: "/2018-06-01/runtime/invocation/next",
method: "GET",
agent: this.agent,
headers: {
"User-Agent": this.userAgent,
},
};
return new Promise((resolve, reject) => {
const request = this.http.request(options, (response) => {
let data = "";
response
.setEncoding("utf-8")
.on("data", (chunk) => {
data += chunk;
})
.on("end", () => {
resolve({
bodyJson: data,
headers: response.headers,
});
});
});
request
.on("error", (e) => {
reject(e);
})
.end();
});
}
return this.nativeClient.next();
}