Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: node 20 hangs if reponse body is not read #43

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dist/channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ async function archiveChannel(vendorPortalApi, appSlug, channelSlug) {
if (archiveChannelRes.message.statusCode != 200) {
throw new Error(`Failed to archive channel: Server responded with ${archiveChannelRes.message.statusCode}`);
}
// discard the response body
await archiveChannelRes.readBody();
}
exports.archiveChannel = archiveChannel;
async function findChannelDetailsInOutput(channels, { slug, name }) {
Expand Down
6 changes: 6 additions & 0 deletions dist/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ async function removeCluster(vendorPortalApi, clusterId) {
if (res.message.statusCode != 200) {
throw new StatusError(`Failed to remove cluster: Server responded with ${res.message.statusCode}`, res.message.statusCode);
}
// discard the response body
await res.readBody();
}
exports.removeCluster = removeCluster;
async function upgradeCluster(vendorPortalApi, clusterId, k8sVersion) {
Expand All @@ -168,6 +170,10 @@ async function upgradeCluster(vendorPortalApi, clusterId, k8sVersion) {
if (res.message.statusCode != 200) {
throw new StatusError(`Failed to upgrade cluster: Server responded with ${res.message.statusCode}`, res.message.statusCode);
}
else {
// discard the response body
await res.readBody();
}
return getClusterDetails(vendorPortalApi, clusterId);
}
exports.upgradeCluster = upgradeCluster;
Expand Down
6 changes: 6 additions & 0 deletions dist/customers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ async function createCustomer(vendorPortalApi, appSlug, name, email, licenseType
if (downloadLicenseRes.message.statusCode == 200) {
downloadLicenseBody = await downloadLicenseRes.readBody();
}
else {
// discard the response body
await downloadLicenseRes.readBody();
}
return { name: name, customerId: createCustomerBody.customer.id, licenseId: createCustomerBody.customer.installationId, license: downloadLicenseBody };
}
catch (error) {
Expand All @@ -80,6 +84,8 @@ async function archiveCustomer(vendorPortalApi, customerId) {
if (archiveCustomerRes.message.statusCode != 204) {
throw new Error(`Failed to archive customer: Server responded with ${archiveCustomerRes.message.statusCode}`);
}
// discard the response body
await archiveCustomerRes.readBody();
}
exports.archiveCustomer = archiveCustomer;
async function getUsedKubernetesDistributions(vendorPortalApi, appSlug) {
Expand Down
4 changes: 4 additions & 0 deletions dist/releases.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ async function promoteReleaseByAppId(vendorPortalApi, appId, channelId, releaseS
}
throw new Error(`Failed to promote release: Server responded with ${res.message.statusCode}: ${body}`);
}
// discard the response body
await res.readBody();
}
async function isReleaseReadyForInstall(vendorPortalApi, appId, releaseSequence) {
var _a;
Expand Down Expand Up @@ -271,4 +273,6 @@ async function reportCompatibilityResultByAppId(vendorPortalApi, appId, releaseS
}
throw new Error(`Failed to report compatibility results: Server responded with ${res.message.statusCode}: ${body}`);
}
// discard the response body
await res.readBody();
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "replicated-lib",
"version": "0.0.1-beta.13",
"version": "0.0.1-beta.14",
"description": "Can interact with the vendor portal api!",
"scripts": {
"build": "rm -rf dist && tsc --build",
Expand Down
2 changes: 2 additions & 0 deletions src/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export async function archiveChannel(vendorPortalApi: VendorPortalApi, appSlug:
if (archiveChannelRes.message.statusCode != 200) {
throw new Error(`Failed to archive channel: Server responded with ${archiveChannelRes.message.statusCode}`);
}
// discard the response body
await archiveChannelRes.readBody();
}

async function findChannelDetailsInOutput(channels: any[], { slug, name }: ChannelIdentifier): Promise<Channel> {
Expand Down
7 changes: 6 additions & 1 deletion src/clusters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ export async function removeCluster(vendorPortalApi: VendorPortalApi, clusterId:

const uri = `${vendorPortalApi.endpoint}/cluster/${clusterId}`;
const res = await http.del(uri);
if (res.message.statusCode != 200) {
if (res.message.statusCode != 201) {
throw new StatusError(`Failed to remove cluster: Server responded with ${res.message.statusCode}`, res.message.statusCode);
}
// discard the response body
await res.readBody();
}

export async function upgradeCluster(vendorPortalApi: VendorPortalApi, clusterId: string, k8sVersion: string): Promise<Cluster> {
Expand All @@ -249,6 +251,9 @@ export async function upgradeCluster(vendorPortalApi: VendorPortalApi, clusterId
const res = await http.post(uri, JSON.stringify(reqBody));
if (res.message.statusCode != 200) {
throw new StatusError(`Failed to upgrade cluster: Server responded with ${res.message.statusCode}`, res.message.statusCode);
} else {
// discard the response body
await res.readBody();
}

return getClusterDetails(vendorPortalApi, clusterId);
Expand Down
5 changes: 5 additions & 0 deletions src/customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export async function createCustomer(vendorPortalApi: VendorPortalApi, appSlug:
let downloadLicenseBody: string = "";
if (downloadLicenseRes.message.statusCode == 200) {
downloadLicenseBody = await downloadLicenseRes.readBody();
} else {
// discard the response body
await downloadLicenseRes.readBody();
}

return { name: name, customerId: createCustomerBody.customer.id, licenseId: createCustomerBody.customer.installationId, license: downloadLicenseBody };
Expand All @@ -101,6 +104,8 @@ export async function archiveCustomer(vendorPortalApi: VendorPortalApi, customer
if (archiveCustomerRes.message.statusCode != 204) {
throw new Error(`Failed to archive customer: Server responded with ${archiveCustomerRes.message.statusCode}`);
}
// discard the response body
await archiveCustomerRes.readBody();
}

export async function getUsedKubernetesDistributions(vendorPortalApi: VendorPortalApi, appSlug: string): Promise<KubernetesDistribution[]> {
Expand Down
4 changes: 4 additions & 0 deletions src/releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ async function promoteReleaseByAppId(vendorPortalApi: VendorPortalApi, appId: st
}
throw new Error(`Failed to promote release: Server responded with ${res.message.statusCode}: ${body}`);
}
// discard the response body
await res.readBody();
}

async function isReleaseReadyForInstall(vendorPortalApi: VendorPortalApi, appId: string, releaseSequence: number): Promise<boolean> {
Expand Down Expand Up @@ -329,4 +331,6 @@ async function reportCompatibilityResultByAppId(vendorPortalApi: VendorPortalApi
}
throw new Error(`Failed to report compatibility results: Server responded with ${res.message.statusCode}: ${body}`);
}
// discard the response body
await res.readBody();
}
Loading