thombuchi / ghost-google-cloud-storage

A simple plugin to add Google Cloud Storage support for Ghost Blog
MIT License
43 stars 38 forks source link

InternalServerError: Cannot read property 'maxAge' of undefined #9

Closed guilhermecaldas closed 6 years ago

guilhermecaldas commented 6 years ago

When I try to upload an image in a post in development mode, I receive this error in console and my page keep stuck in uploading message:

ERROR [2017-11-21 18:04:31] "POST /ghost/api/v0.1/uploads/" 500 645ms

NAME: InternalServerError
MESSAGE: Cannot read property 'maxAge' of undefined

level:normal

InternalServerError: Cannot read property 'maxAge' of undefined
    at new GhostError (/home/ubuntu/workspace/ghost-alest/ghost/core/server/errors.js:9:26)
    at prepareError (/home/ubuntu/workspace/ghost-alest/ghost/core/server/middleware/error-handler.js:40:19)
    at Layer.handle_error (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/layer.js:71:5)
    at trim_prefix (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:315:13)
    at /home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:335:12)
    at next (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:275:10)
    at Layer.handle_error (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/layer.js:67:12)
    at trim_prefix (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:315:13)
    at /home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:335:12)
    at next (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:275:10)
    at /home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:635:15
    at next (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/index.js:260:14)
    at next (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/express/lib/router/route.js:127:14)
    at onAPIError (/home/ubuntu/workspace/ghost-alest/ghost/core/server/api/index.js:286:13)
    at tryCatcher (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:689:18)
    at Async._drainQueue (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/async.js:133:16)

TypeError: Cannot read property 'maxAge' of undefined
    at /home/ubuntu/workspace/ghost-alest/ghost/node_modules/ghost-google-cloud-storage/index.js:41:62
    at tryCatcher (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/ubuntu/workspace/ghost-alest/ghost/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

It happens with or without ageMaxparam in config file. My workaround was force ageMax value in node_modules/ghost-google-cloud-storage/index.js:41:62

zackify commented 6 years ago

I made a pr that should fix it. https://github.com/thombuchi/ghost-google-cloud-storage/pull/11 Hope it can get merged soon...

zackify commented 6 years ago

Really, arrows can be used to fix all the self stuff in this lib, since ghost only supports versions of node with arrow functions now.