Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show http request code to avoid random failures with empty error #4237

Merged
merged 1 commit into from
May 15, 2017
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
2 changes: 1 addition & 1 deletion Tasks/VSMobileCenterUpload/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 0,
"Minor": 117,
"Patch": 1
"Patch": 2
},
"groups": [
{
Expand Down
2 changes: 1 addition & 1 deletion Tasks/VSMobileCenterUpload/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 0,
"Minor": 117,
"Patch": 1
"Patch": 2
},
"groups": [
{
Expand Down
40 changes: 23 additions & 17 deletions Tasks/VSMobileCenterUpload/vsmobilecenterupload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tl = require('vsts-task-lib/task');
import request = require('request');
import Q = require('q');
import fs = require('fs');
import os = require('os');

import { ToolRunner } from 'vsts-task-lib/toolrunner';

Expand Down Expand Up @@ -57,7 +58,12 @@ function responseHandler(defer, err, res, body, handler: () => void) {

tl.debug(`---- http call status code: ${res.statusCode}`);
if (res.statusCode < 200 || res.statusCode >= 300) {
let message = JSON.stringify(body) || `http response code: ${res.statusCode}`;
let message = JSON.stringify(body);
if (!message) {
message = `http response code: ${res.statusCode}`;
} else {
message = message.concat(os.EOL + `http response code: ${res.statusCode}`);
}
defer.reject(message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also use ${JSON.stringify(err)} instead of just ${err} at the end of the file. Also, tl.error(...) call won't hurt before tl.setResult(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both suggestions while they don't hurt are not required. Based on my experiments with node REPL, I am fairly confident about the fix I made being sufficient :). At least we will always get the http response code every time.

return;
}
Expand Down Expand Up @@ -171,34 +177,34 @@ function publishRelease(apiServer: string, releaseUrl: string, releaseNotes: str
* If the input is a single folder, zip it's content. The archive name is the folder's name
* If the input is a set of folders or files, zip them so they appear on the root of the archive. The archive name is the parent folder's name.
*/
function prepareSymbols(symbolsPaths: string[]): Q.Promise<string> {
function prepareSymbols(symbolsPaths: string[]): Q.Promise<string> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting changes (Shift + Option + F) in VSCode on macOS.

tl.debug("-- Prepare symbols");
let defer = Q.defer<string>();
let defer = Q.defer<string>();

if (symbolsPaths.length === 1 && fs.statSync(symbolsPaths[0]).isFile()) {
tl.debug(`.. a single symbols file: ${symbolsPaths[0]}`)
tl.debug(`.. a single symbols file: ${symbolsPaths[0]}`)

// single file - Android source mapping txt file
defer.resolve(symbolsPaths[0]);
} else if (symbolsPaths.length > 0) {
tl.debug(`.. archiving: ${symbolsPaths}`);
defer.resolve(symbolsPaths[0]);
} else if (symbolsPaths.length > 0) {
tl.debug(`.. archiving: ${symbolsPaths}`);

let symbolsRoot = utils.findCommonParent(symbolsPaths);
let zipPath = utils.getArchivePath(symbolsRoot);
let zipStream = utils.createZipStream(symbolsPaths, symbolsRoot);
let zipStream = utils.createZipStream(symbolsPaths, symbolsRoot);

utils.createZipFile(zipStream, zipPath).
then(() => {
tl.debug(`---- symbols arechive file: ${zipPath}`)
defer.resolve(zipPath);
});
utils.createZipFile(zipStream, zipPath).
then(() => {
tl.debug(`---- symbols arechive file: ${zipPath}`)
defer.resolve(zipPath);
});
} else {
defer.resolve(null);
defer.resolve(null);
}


return defer.promise;
}
return defer.promise;
}

function beginSymbolUpload(apiServer: string, apiVersion: string, appSlug: string, symbol_type: string, token: string, userAgent: string): Q.Promise<SymbolsUploadInfo> {
tl.debug("-- Begin symbols upload")
Expand Down Expand Up @@ -277,7 +283,7 @@ function commitSymbols(apiServer: string, apiVersion: string, appSlug: string, s

function expandSymbolsPaths(symbolsType: string, pattern: string, continueOnError: boolean, packParentFolder: boolean): string[] {
tl.debug("-- Expanding symbols path pattern to a list of paths");

let symbolsPaths: string[] = [];

if (symbolsType === "Apple") {
Expand Down