gcs: ensure handlers are attached before write

This commit is contained in:
Girish Ramakrishnan
2025-12-03 20:36:55 +01:00
parent 550df1be89
commit 61b5ab8a49

View File

@@ -256,7 +256,7 @@ async function verifyConfig({ id, provider, config }) {
const uploadStream = testFile.createWriteStream({ resumable: false });
await new Promise((resolve, reject) => {
uploadStream.on('error', function(error) {
uploadStream.on('error', (error) => {
debug('testConfig: failed uploading cloudron-testfile. %o', error);
if (error && error.code && (error.code == 403 || error.code == 404)) {
return reject(new BoxError(BoxError.BAD_FIELD, error.message));
@@ -264,10 +264,8 @@ async function verifyConfig({ id, provider, config }) {
return reject(new BoxError(BoxError.EXTERNAL_ERROR, error.message));
});
uploadStream.write('testfilecontents');
uploadStream.end();
uploadStream.on('finish', resolve);
uploadStream.end('testfilecontents');
});
debug('testConfig: uploaded cloudron-testfile');