ionic-team / ionic-app-lib

The library used for using ionic apps - consumed by the CLI and the GUI
44 stars 79 forks source link

ionic resources fails silently #53

Open flanger001 opened 8 years ago

flanger001 commented 8 years ago

To start: apologies if I am posting this in the wrong place; I'm not sure where else this would go.

I am developing an Ionic app and wanted to use ionic resources to generate the icons. When I would run the command, I would see nothing but "uploading icon.png" and "uploading splash.png", then the script would terminate and nothing would change. I did some digging (and a lot of console.log-ing and traced where the failure was occurring to loadSourceImages() in lib/resources.js.

I added some logging code to the reject function:

// Rest of function truncated
request.post(postData, function(err, httpResponse, body) {
      function reject(msg) {
        try {
          msg += JSON.parse(body).Error;
        } catch (e) {
          msg += body || '';
        }
        console.log('Error: ', err)
        console.log('Response: ', httpResponse);
        console.log(msg);
        deferred.reject(msg);
      }
// etc

And got this (apologies in advance, it is the entire httpResponse):

err:  null
httpResponse:  IncomingMessage {
  _readableState: 
   ReadableState {
     objectMode: false,
     highWaterMark: 16384,
     buffer: [],
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: true,
     ended: true,
     endEmitted: true,
     reading: false,
     sync: true,
     needReadable: false,
     emittedReadable: false,
     readableListening: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null,
     resumeScheduled: false },
  readable: false,
  domain: null,
  _events: 
   { end: [ [Function: responseOnEnd], [Function], [Function], [Function] ],
     close: [ [Function], [Function] ],
     data: [Function],
     error: [Function] },
  _eventsCount: 4,
  _maxListeners: undefined,
  socket: 
   Socket {
     _connecting: false,
     _hadError: false,
     _handle: null,
     _parent: null,
     _host: 'res.ionic.io',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null,
        resumeScheduled: false },
     readable: false,
     domain: null,
     _events: 
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        free: [Function: onFree],
        close: [Object],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Object] },
     _eventsCount: 8,
     _maxListeners: 0,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false },
     writable: false,
     allowHalfOpen: false,
     destroyed: true,
     bytesRead: 446,
     _bytesDispatched: 179402,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     parser: null,
     _httpMessage: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header: 'POST /api/v1/upload HTTP/1.1\r\nhost: res.ionic.io\r\ncontent-type: multipart/form-data; boundary=--------------------------631543885612979365451996\r\ncontent-length: 179211\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        method: 'POST',
        path: '/api/v1/upload',
        parser: null,
        res: [Circular] },
     read: [Function],
     _consuming: true,
     _idleNext: null,
     _idlePrev: null,
     _idleTimeout: -1 },
  connection: 
   Socket {
     _connecting: false,
     _hadError: false,
     _handle: null,
     _parent: null,
     _host: 'res.ionic.io',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null,
        resumeScheduled: false },
     readable: false,
     domain: null,
     _events: 
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        free: [Function: onFree],
        close: [Object],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Object] },
     _eventsCount: 8,
     _maxListeners: 0,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false },
     writable: false,
     allowHalfOpen: false,
     destroyed: true,
     bytesRead: 446,
     _bytesDispatched: 179402,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     parser: null,
     _httpMessage: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header: 'POST /api/v1/upload HTTP/1.1\r\nhost: res.ionic.io\r\ncontent-type: multipart/form-data; boundary=--------------------------631543885612979365451996\r\ncontent-length: 179211\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        method: 'POST',
        path: '/api/v1/upload',
        parser: null,
        res: [Circular] },
     read: [Function],
     _consuming: true,
     _idleNext: null,
     _idlePrev: null,
     _idleTimeout: -1 },
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers: 
   { date: 'Tue, 29 Dec 2015 19:25:35 GMT',
     'content-type': 'text/plain; charset=utf-8',
     'content-length': '90',
     connection: 'close',
     'set-cookie': [ '__cfduid=d0d063624703b9d9d9fd6385cd77582421451417134; expires=Wed, 28-Dec-16 19:25:34 GMT; path=/; domain=.ionic.io; HttpOnly' ],
     via: '1.1 vegur',
     server: 'cloudflare-nginx',
     'cf-ray': '25c7e4423bd1041e-ORD' },
  rawHeaders: 
   [ 'Date',
     'Tue, 29 Dec 2015 19:25:35 GMT',
     'Content-Type',
     'text/plain; charset=utf-8',
     'Content-Length',
     '90',
     'Connection',
     'close',
     'Set-Cookie',
     '__cfduid=d0d063624703b9d9d9fd6385cd77582421451417134; expires=Wed, 28-Dec-16 19:25:34 GMT; path=/; domain=.ionic.io; HttpOnly',
     'Via',
     '1.1 vegur',
     'Server',
     'cloudflare-nginx',
     'CF-RAY',
     '25c7e4423bd1041e-ORD' ],
  trailers: {},
  rawTrailers: [],
  upgrade: false,
  url: '',
  method: null,
  statusCode: 400,
  statusMessage: 'Bad Request',
  client: 
   Socket {
     _connecting: false,
     _hadError: false,
     _handle: null,
     _parent: null,
     _host: 'res.ionic.io',
     _readableState: 
      ReadableState {
        objectMode: false,
        highWaterMark: 16384,
        buffer: [],
        length: 0,
        pipes: null,
        pipesCount: 0,
        flowing: true,
        ended: false,
        endEmitted: false,
        reading: true,
        sync: false,
        needReadable: true,
        emittedReadable: false,
        readableListening: false,
        defaultEncoding: 'utf8',
        ranOut: false,
        awaitDrain: 0,
        readingMore: false,
        decoder: null,
        encoding: null,
        resumeScheduled: false },
     readable: false,
     domain: null,
     _events: 
      { end: [Object],
        finish: [Function: onSocketFinish],
        _socketEnd: [Function: onSocketEnd],
        free: [Function: onFree],
        close: [Object],
        agentRemove: [Function: onRemove],
        drain: [Function: ondrain],
        error: [Object] },
     _eventsCount: 8,
     _maxListeners: 0,
     _writableState: 
      WritableState {
        objectMode: false,
        highWaterMark: 16384,
        needDrain: false,
        ending: true,
        ended: true,
        finished: true,
        decodeStrings: false,
        defaultEncoding: 'utf8',
        length: 0,
        writing: false,
        corked: 0,
        sync: false,
        bufferProcessing: false,
        onwrite: [Function],
        writecb: null,
        writelen: 0,
        bufferedRequest: null,
        lastBufferedRequest: null,
        pendingcb: 0,
        prefinished: true,
        errorEmitted: false },
     writable: false,
     allowHalfOpen: false,
     destroyed: true,
     bytesRead: 446,
     _bytesDispatched: 179402,
     _sockname: null,
     _pendingData: null,
     _pendingEncoding: '',
     parser: null,
     _httpMessage: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Circular],
        connection: [Circular],
        _header: 'POST /api/v1/upload HTTP/1.1\r\nhost: res.ionic.io\r\ncontent-type: multipart/form-data; boundary=--------------------------631543885612979365451996\r\ncontent-length: 179211\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        method: 'POST',
        path: '/api/v1/upload',
        parser: null,
        res: [Circular] },
     read: [Function],
     _consuming: true,
     _idleNext: null,
     _idlePrev: null,
     _idleTimeout: -1 },
  _consuming: true,
  _dumped: false,
  req: 
   ClientRequest {
     domain: null,
     _events: 
      { socket: [Object],
        response: [Function: bound ],
        error: [Function: bound ],
        drain: [Function] },
     _eventsCount: 4,
     _maxListeners: undefined,
     output: [],
     outputEncodings: [],
     outputCallbacks: [],
     outputSize: 0,
     writable: true,
     _last: true,
     chunkedEncoding: false,
     shouldKeepAlive: false,
     useChunkedEncodingByDefault: true,
     sendDate: false,
     _removedHeader: { 'content-length': false },
     _contentLength: null,
     _hasBody: true,
     _trailer: '',
     finished: true,
     _headerSent: true,
     socket: 
      Socket {
        _connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'res.ionic.io',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 8,
        _maxListeners: 0,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        destroyed: true,
        bytesRead: 446,
        _bytesDispatched: 179402,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1 },
     connection: 
      Socket {
        _connecting: false,
        _hadError: false,
        _handle: null,
        _parent: null,
        _host: 'res.ionic.io',
        _readableState: [Object],
        readable: false,
        domain: null,
        _events: [Object],
        _eventsCount: 8,
        _maxListeners: 0,
        _writableState: [Object],
        writable: false,
        allowHalfOpen: false,
        destroyed: true,
        bytesRead: 446,
        _bytesDispatched: 179402,
        _sockname: null,
        _pendingData: null,
        _pendingEncoding: '',
        parser: null,
        _httpMessage: [Circular],
        read: [Function],
        _consuming: true,
        _idleNext: null,
        _idlePrev: null,
        _idleTimeout: -1 },
     _header: 'POST /api/v1/upload HTTP/1.1\r\nhost: res.ionic.io\r\ncontent-type: multipart/form-data; boundary=--------------------------631543885612979365451996\r\ncontent-length: 179211\r\nConnection: close\r\n\r\n',
     _headers: 
      { host: 'res.ionic.io',
        'content-type': 'multipart/form-data; boundary=--------------------------631543885612979365451996',
        'content-length': 179211 },
     _headerNames: 
      { host: 'host',
        'content-type': 'content-type',
        'content-length': 'content-length' },
     _onPendingData: null,
     agent: 
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 80,
        protocol: 'http:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256 },
     socketPath: undefined,
     method: 'POST',
     path: '/api/v1/upload',
     parser: null,
     res: [Circular] },
  request: 
   Request {
     domain: null,
     _events: 
      { error: [Object],
        complete: [Function: bound ],
        pipe: [Function],
        end: [Object],
        data: [Function] },
     _eventsCount: 5,
     _maxListeners: undefined,
     callback: [Function],
     uri: 
      Url {
        protocol: 'http:',
        slashes: true,
        auth: null,
        host: 'res.ionic.io',
        port: 80,
        hostname: 'res.ionic.io',
        hash: null,
        search: null,
        query: null,
        pathname: '/api/v1/upload',
        path: '/api/v1/upload',
        href: 'http://res.ionic.io/api/v1/upload' },
     proxy: null,
     formData: { image_id: '8150f4c1', src: [Object] },
     method: 'POST',
     readable: true,
     writable: true,
     explicitMethod: true,
     canTunnel: false,
     headers: 
      { 'content-type': 'multipart/form-data; boundary=--------------------------631543885612979365451996',
        'content-length': 179211 },
     setHeader: [Function],
     hasHeader: [Function],
     getHeader: [Function],
     removeHeader: [Function],
     localAddress: undefined,
     qsLib: { stringify: [Function], parse: [Function] },
     pool: {},
     dests: [],
     __isRequestRequest: true,
     _callback: [Function],
     tunnel: false,
     _redirectsFollowed: 0,
     maxRedirects: 10,
     allowRedirect: [Function],
     followRedirects: true,
     followAllRedirects: false,
     redirects: [],
     setHost: true,
     originalCookieHeader: undefined,
     _disableCookies: true,
     _jar: undefined,
     port: 80,
     host: 'res.ionic.io',
     _form: 
      FormData {
        _overheadLength: 255,
        _valueLength: 8,
        _lengthRetrievers: [Object],
        writable: false,
        readable: true,
        dataSize: 0,
        maxDataSize: 2097152,
        pauseStreams: true,
        _released: true,
        _streams: [],
        _currentStream: null,
        _boundary: '--------------------------631543885612979365451996',
        _events: {},
        _eventsCount: 0 },
     path: '/api/v1/upload',
     httpModule: 
      { IncomingMessage: [Object],
        METHODS: [Object],
        OutgoingMessage: [Object],
        ServerResponse: [Object],
        STATUS_CODES: [Object],
        Agent: [Object],
        globalAgent: [Object],
        ClientRequest: [Object],
        request: [Function],
        get: [Function],
        _connectionListener: [Function: connectionListener],
        Server: [Object],
        createServer: [Function],
        Client: [Function: deprecated],
        createClient: [Function: deprecated] },
     agentClass: { [Function: Agent] super_: [Object], defaultMaxSockets: Infinity },
     agent: 
      Agent {
        domain: null,
        _events: [Object],
        _eventsCount: 1,
        _maxListeners: undefined,
        defaultPort: 80,
        protocol: 'http:',
        options: [Object],
        requests: {},
        sockets: [Object],
        freeSockets: {},
        keepAliveMsecs: 1000,
        keepAlive: false,
        maxSockets: Infinity,
        maxFreeSockets: 256 },
     ntick: true,
     src: 
      FormData {
        _overheadLength: 255,
        _valueLength: 8,
        _lengthRetrievers: [Object],
        writable: false,
        readable: true,
        dataSize: 0,
        maxDataSize: 2097152,
        pauseStreams: true,
        _released: true,
        _streams: [],
        _currentStream: null,
        _boundary: '--------------------------631543885612979365451996',
        _events: {},
        _eventsCount: 0 },
     _started: true,
     href: 'http://res.ionic.io/api/v1/upload',
     req: 
      ClientRequest {
        domain: null,
        _events: [Object],
        _eventsCount: 4,
        _maxListeners: undefined,
        output: [],
        outputEncodings: [],
        outputCallbacks: [],
        outputSize: 0,
        writable: true,
        _last: true,
        chunkedEncoding: false,
        shouldKeepAlive: false,
        useChunkedEncodingByDefault: true,
        sendDate: false,
        _removedHeader: [Object],
        _contentLength: null,
        _hasBody: true,
        _trailer: '',
        finished: true,
        _headerSent: true,
        socket: [Object],
        connection: [Object],
        _header: 'POST /api/v1/upload HTTP/1.1\r\nhost: res.ionic.io\r\ncontent-type: multipart/form-data; boundary=--------------------------631543885612979365451996\r\ncontent-length: 179211\r\nConnection: close\r\n\r\n',
        _headers: [Object],
        _headerNames: [Object],
        _onPendingData: null,
        agent: [Object],
        socketPath: undefined,
        method: 'POST',
        path: '/api/v1/upload',
        parser: null,
        res: [Circular] },
     response: [Circular],
     originalHost: 'res.ionic.io',
     originalHostHeaderName: 'host',
     _destdata: true,
     _ended: true,
     _callbackCalled: true },
  toJSON: [Function: responseToJSON],
  caseless: 
   Caseless {
     dict: 
      { date: 'Tue, 29 Dec 2015 19:25:35 GMT',
        'content-type': 'text/plain; charset=utf-8',
        'content-length': '90',
        connection: 'close',
        'set-cookie': [Object],
        via: '1.1 vegur',
        server: 'cloudflare-nginx',
        'cf-ray': '25c7e4423bd1041e-ORD' } },
  read: [Function],
  body: '{"Error":"unable to read uploaded image","Width":0,"Height":0,"Type":"png","Vector":false}' }
Invalid upload: unable to read uploaded image

Before the logging, I would just get nothing.

Even with all of that information, I am not sure what to make of it. My file is a perfectly valid 1024x1024 24-bit png image without transparency, and other images of different sizes didn't give me any better results. The promise code is clearly doing what it is supposed to, and yet I still cannot seem to figure out what to do to upload my image.

Again, apologies if I posted this in the wrong place but this seemed like where I thought it should go. Am I doing something wrong, or is there actually an issue here?

habbes commented 8 years ago

I'm getting the same result, I only figured out the error after inserting console.log() statements in the cli source.

habbes commented 8 years ago

In my case the images are png's with transparent backgrounds.

habbes commented 8 years ago

I removed the transparency and now it seems to work