Skip to content

Commit

Permalink
SNOW-1926267: Fix promise rejecting for file upload errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pmotacki committed Mar 4, 2025
1 parent 4d82d7e commit ad6e136
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions lib/connection/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -842,18 +842,19 @@ function FileStatementPreExec(
async function executeFileTransferRequest(context, body, statement, fileTransferAgent) {
context.fileMetadata = body;

const fta = typeof fileTransferAgent === 'undefined' ? new FileTransferAgent(context) : fileTransferAgent;
await fta.execute();
const fta = fileTransferAgent ?? new FileTransferAgent(context); await fta.execute();

try {
// build a result from the response
const result = fta.result();

// init result and meta
body.data.rowset = result.rowset;
body.data.returned = body.data.rowset.length;
body.data.rowtype = result.rowtype;
body.data.parameters = [];
body.data = {
rowset: result.rowset,
returned: body.data.rowset.length,
rowtype: result.rowtype,
parameters: [],
};

context.result = new Result({
response: body,
Expand Down
6 changes: 3 additions & 3 deletions lib/file_transfer_agent/file_transfer_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function FileTransferAgent(context) {
if (meta['resultStatus'] === 'ERROR') {
errorDetails = meta['errorDetails'];
if (!errorDetails) {
errorDetails = `Unknown error during PUT of file: ${meta['srcFilePath'].toString()}`;
errorDetails = `Unknown error during PUT of file: ${meta['srcFilePath']}`;
}
throw new Error(errorDetails);
}
Expand All @@ -234,8 +234,8 @@ function FileTransferAgent(context) {

errorDetails = meta['errorDetails'];

srcFileSize = meta['srcFileSize'].toString();
dstFileSize = meta['dstFileSize'].toString();
srcFileSize = meta['srcFileSize'];
dstFileSize = meta['dstFileSize'];

rowset.push([
meta['srcFileName'],
Expand Down

0 comments on commit ad6e136

Please sign in to comment.