running the seeder in v6 #4523
Answered
by
RomainLanz
jasonejavier
asked this question in
Help
-
Beta Was this translation helpful? Give feedback.
Answered by
RomainLanz
Apr 16, 2024
Replies: 1 comment 1 reply
-
Hey @jasonejavier! 👋🏻 Since you are using a stream, you are not properly awaiting the end of your processing. I would recommend creating a dedicated method that does the processing and makes it return a promise. export default class extends BaseSeeder {
async run() {
// ...
await this.#processsCsvFile(csvFilePath)
}
async #proccessCsvFile(filePath: string) {
return new Promise((resolve, reject) => {
createReadStream(csvFilePath)
.on('end', () => {
// ...
resolve()
})
.on('error', () => {
// ...
reject()
})
})
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jasonejavier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @jasonejavier! 👋🏻
Since you are using a stream, you are not properly awaiting the end of your processing.
I would recommend creating a dedicated method that does the processing and makes it return a promise.
Something like: