Merge pull request #3375 from Human-Connection/set-maxSockets-to-avoid-rate-limit-error

fix(migration): Set maxSockets to avoid rate limit
This commit is contained in:
Robert Schäfer 2020-03-30 22:09:32 +02:00 committed by GitHub
commit f9e5d84779
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import path from 'path'
import { S3 } from 'aws-sdk'
import mime from 'mime-types'
import { s3Configs } from '../../config'
import https from 'https'
export const description = `
Upload all image files to a S3 compatible object storage in order to reduce
@ -14,6 +15,9 @@ export async function up(next) {
const driver = getDriver()
const session = driver.session()
const transaction = session.beginTransaction()
const agent = new https.Agent({
maxSockets: 5,
})
const {
AWS_ENDPOINT: endpoint,
@ -28,7 +32,7 @@ export async function up(next) {
return
}
const s3 = new S3({ region, endpoint })
const s3 = new S3({ region, endpoint, httpOptions: { agent } })
try {
// Implement your migration here.
const { records } = await transaction.run('MATCH (image:Image) RETURN image.url as url')