Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

INT-11156: wrap in try/catch timeout #24

Merged
merged 2 commits into from
Jul 4, 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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
"postversion": "cp package.json ./dist/package.json"
},
"peerDependencies": {
"@jupiterone/integration-sdk-core": "^10.0.0"
"@jupiterone/integration-sdk-core": "^13.1.1"
},
"devDependencies": {
"@jupiterone/integration-sdk-core": "^10.0.0",
"@jupiterone/integration-sdk-dev-tools": "^10.0.0",
"@jupiterone/integration-sdk-testing": "^10.0.0",
"@jupiterone/integration-sdk-core": "^13.1.1",
"@jupiterone/integration-sdk-dev-tools": "^13.1.1",
"@jupiterone/integration-sdk-testing": "^13.1.1",
"@types/mssql": "^8.1.2",
"auto": "^10.36.5"
},
Expand Down
55 changes: 29 additions & 26 deletions src/configuration-manager/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ class MicrosoftConfigurationManagerClient {

const records = result.recordset;

logger.info(`Proccesed ${records.length} records from query`);

if (records.length > 0) {
await pMap(
records,
Expand Down Expand Up @@ -175,37 +173,42 @@ class MicrosoftConfigurationManagerClient {
async listCollectionSubscriptions<T>(
tableName: string,
iteratee: ResourceIteratee<T>,
logger: IntegrationLogger,
pageSize: number = 200,
) {
let offset = 0;
let hasMoreRecords = true;

while (hasMoreRecords) {
const query = buildCollectionSubscriptionQuery(
this.dbName,
tableName,
offset,
pageSize,
);
const result = await this.wrapWithRequestFailedHandler(() =>
this.connection.query(query),
);

const records = result.recordset;
if (records.length > 0) {
await pMap(
records,
async (record) => {
await iteratee(record);
},
{
concurrency: 2,
},
try {
while (hasMoreRecords) {
const query = buildCollectionSubscriptionQuery(
this.dbName,
tableName,
offset,
pageSize,
);
offset += pageSize;
} else {
hasMoreRecords = false;
const result = await this.wrapWithRequestFailedHandler(() =>
this.connection.query(query),
);

const records = result.recordset;
if (records.length > 0) {
await pMap(
records,
async (record) => {
await iteratee(record);
},
{
concurrency: 2,
},
);
offset += pageSize;
} else {
hasMoreRecords = false;
}
}
} catch (err) {
logger.info(`Received SQL error when processing query: ${err}`);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const invocationConfig: IntegrationInvocationConfig<IntegrationConfig> =
instanceConfigFields,
validateInvocation,
integrationSteps,
stepConcurrency: 1,
async afterExecution(context) {
try {
await close(context.logger);
Expand Down
1 change: 1 addition & 0 deletions src/steps/collections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export async function buildCollectionsRelationships({
);
}
},
logger,
);
}
},
Expand Down
Loading
Loading