简体   繁体   中英

Sails fails to lift after simple update

I have a server running on aws elastic beanstalk. It's pretty much been fine. but today when applying an update(Absolutely nothing to do with configs or versioning of modules used) which was simply adding a few words to some text in the web app (Literally the word 'dog'). The app started crashing with 502 nginx gateway errors. I assume this is because the app is not lifying. I went and reverted the change(Though I did not think I had to do so). and the problem persists.

My output when attempting to lift / start the sails app is as follows.

    Failed to load helper `web/auth/validate-user-password` as a machine!
A hook (`helpers`) failed to load!
Failed to lift app: ImplementationError: Sorry, could not interpret "web/auth/validate-user-password" because its underlying implementation has a problem:
------------------------------------------------------
• The `cacheable` property is no longer supported.  (Please use `sideEffects: 'cacheable' instead.)
------------------------------------------------------

If you are the maintainer of "web/auth/validate-user-password", then you can change its implementation to solve the problem above.  Otherwise, please file a bug report with the maintainer, or fork your own copy and fix that.
 [?] See https://sailsjs.com/support for help.
    at flaverr (/var/app/current/node_modules/flaverr/index.js:77:15)
    at helpBuildMachine (/var/app/current/node_modules/sails/node_modules/machine/lib/private/help-build-machine.js:127:11)
    at Function.build (/var/app/current/node_modules/sails/node_modules/machine/lib/build.js:52:10)
    at /var/app/current/node_modules/sails/lib/hooks/helpers/load-helpers.js:51:49
    at /var/app/current/node_modules/@sailshq/lodash/lib/index.js:3228:15
    at baseForOwn (/var/app/current/node_modules/@sailshq/lodash/lib/index.js:2199:14)
    at /var/app/current/node_modules/@sailshq/lodash/lib/index.js:3198:18
    at Function.<anonymous> (/var/app/current/node_modules/@sailshq/lodash/lib/index.js:3501:13)
    at /var/app/current/node_modules/sails/lib/hooks/helpers/load-helpers.js:37:9
    at helpBuildDictionary (/var/app/current/node_modules/sails/node_modules/include-all/lib/help-build-dictionary.js:135:10)
    at Function.module.exports.optional (/var/app/current/node_modules/sails/node_modules/include-all/index.js:67:10)
    at Hook.loadHelpers (/var/app/current/node_modules/sails/lib/hooks/helpers/load-helpers.js:21:14)
    at Hook.initialize (/var/app/current/node_modules/sails/lib/hooks/helpers/index.js:28:19)
    at Hook.wrapper [as initialize] (/var/app/current/node_modules/@sailshq/lodash/lib/index.js:3250:19)
    at /var/app/current/node_modules/sails/lib/hooks/index.js:88:16
    at /var/app/current/node_modules/async/dist/async.js:486:20
(You are seeing the above error message because no custom callback was programmatically provided to `.lift()`.)
A hook (`orm`) failed to load!

This is what I'm seeing in package.json in case it will be of help.

{
  "name": "sails-xxxxxxx-seed",
  "private": true,
  "version": "0.0.3-147",
  "description": "a Sails application",
  "keywords": [],
  "dependencies": {
    "async": "2.0.1",
    "aws-sdk": "^2.41.0",
    "bcryptjs": "2.3.0",
    "connect-redis": "3.3.0",
    "flaverr": "^1.1.1",
    "lodash": "3.10.1",
    "machinepack-http": "3.1.2",
    "moment-timezone": "0.5.13",
    "pdfmake": "0.1.28",
    "sails": "^1.0.0-32",
    "sails-hook-orm": "^2.0.0-0",
    "sails-hook-sockets": "^1.0.1",
    "sails-mysql": "^1.0.0-13",
    "sails-stdlib": "^0.7.1",
    "sails.io.js": "1.1.9",
    "serve-static": "1.12.3",
    "socket.io-client": "1.7.3",
    "socket.io-redis": "3.1.0",
    "uuid": "3.0.1"
  },
  "devDependencies": {
    "@angular/animations": "~4.1.3",
    "@angular/common": "~4.1.3",
    "@angular/compiler": "~4.1.3",
    "@angular/compiler-cli": "~4.1.3",
    "@angular/core": "~4.1.3",
    "@angular/forms": "~4.1.3",
    "@angular/http": "~4.1.3",
    "@angular/platform-browser": "~4.1.3",
    "@angular/platform-browser-dynamic": "~4.1.3",
    "@angular/platform-server": "~4.1.3",
    "@angular/router": "~4.1.3",
    "@angular/upgrade": "~4.1.3",
    "@swimlane/ngx-datatable": "^8.0.0",
    "@types/jasmine": "^2.5.47",
    "@types/node": "^6.0.48",
    "angular-pipes": "^6.5.1",
    "angular-router-loader": "^0.6.0",
    "angular2-in-memory-web-api": "0.0.21",
    "angular2-moment": "^1.3.3",
    "angular2-template-loader": "^0.6.0",
    "angular2-text-mask": "^8.0.1",
    "awesome-typescript-loader": "^3.1.2",
    "babel-core": "^6.25.0",
    "babel-loader": "^7.0.0",
    "babel-preset-env": "^1.5.2",
    "babel-preset-es2015": "^6.24.1",
    "chart.js": "^2.5.0",
    "clean-webpack-plugin": "0.1.16",
    "clipboard": "^1.6.1",
    "copy-webpack-plugin": "4.0.1",
    "core-js": "^2.4.1",
    "css-loader": "0.27.3",
    "debug": "^2.6.8",
    "ejs-loader": "0.3.0",
    "eslint": "3.19.0",
    "extract-text-webpack-plugin": "2.1.0",
    "file-loader": "^0.11.1",
    "glob": "^7.1.1",
    "ie-shim": "^0.1.0",
    "json2csv": "^3.7.3",
    "knex": "0.13.0",
    "less": "2.7.2",
    "less-loader": "4.0.1",
    "mime-types": "2.1.15",
    "mocha": "^3.2.0",
    "mydatepicker": "^1.9.2",
    "ng-sidebar": "^4.1.1",
    "ng2-charts": "^1.5.0",
    "ng2-table": "^1.3.2",
    "ng2-toastr": "^4.0.1",
    "ng2-validation": "^4.1.0",
    "ngx-bootstrap": "^1.6.6",
    "ngx-progressbar": "^2.0.0",
    "node-sass": "^4.5.2",
    "primeng": "^4.0.0",
    "prompt": "1.0.0",
    "raw-loader": "^0.5.1",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.12",
    "sass-loader": "^6.0.3",
    "semver": "^5.3.0",
    "to-string-loader": "^1.1.4",
    "typescript": "~2.2.1",
    "url-loader": "^0.5.8",
    "waterline-utils": "^1.3.12",
    "webpack": "^2.2.1",
    "webpack-livereload-plugin": "^0.11.0",
    "webpack-merge": "^0.15.0",
    "webpack-watch-livereload-plugin": "0.0.1",
    "zone.js": "~0.6.26"
  },
  "scripts": {
    "start": "NODE_ENV=production node app.js",
    "test": "npm run lint && npm run custom-tests && echo 'Done.'",
    "lint": "node ./node_modules/eslint/bin/eslint . --max-warnings=0 && echo '✔  Your code looks good.'",
    "custom-tests": "echo \"(No other custom tests yet.)\" && echo",
    "version": "node -e 'process.stdout.write((require(\"./package.json\").version))'",
    "bump": "node scripts/bump.js",
    "debug": "node debug app.js",
    "deploy-staging": "sails_environment=web_staging npm run bump && sails_environment=web_staging npm run deploy",
    "deploy-demo": "sails_environment=web_demo npm run bump && npm run deploy",
    "deploy": "cp -r eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && npm run zip && rm .ebbootstrap.sh && node scripts/publish-static-assets && node scripts/deploy-to-eb",
    "zip": "mkdir -p .tmp && rm .tmp/deploy.zip &> /dev/null; zip -9 -r --exclude=node_modules/* --exclude=.tmp/* --exclude=.DS_Store --exclude=.git/* --exclude=config/local.js ./.tmp/deploy.zip .",
    "deploy-alerts-staging": "sails_environment=alerts_staging npm run bump && sails_environment=alerts_staging npm run deploy-alerts",
    "deploy-alerts": "cp eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && cp eb/apps/alerts/cron.yaml cron.yaml && npm run zip-backend && rm cron.yaml .ebbootstrap.sh && node scripts/deploy-to-eb",
    "deploy-rollup-staging": "sails_environment=rollup_staging npm run bump && sails_environment=rollup_staging npm run deploy-rollup",
    "deploy-rollup": "cp eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && cp eb/apps/rollup/cron.yaml cron.yaml && npm run zip-backend && rm cron.yaml .ebbootstrap.sh && node scripts/deploy-to-eb",
    "deploy-devices-staging": "sails_environment=devices_staging npm run bump && sails_environment=devices_staging npm run deploy-devices",
    "deploy-devices": "cp eb/bootstrap/$sails_environment.sh .ebbootstrap.sh && npm run zip-backend && rm .ebbootstrap.sh && node scripts/deploy-to-eb",
    "deploy-device-sim": "cp eb/bootstrap/device_sim.sh .ebbootstrap.sh && cp eb/apps/device-sim/cron.yaml cron.yaml && npm run zip-backend && rm cron.yaml .ebbootstrap.sh && sails_environment=device_sim npm run bump && sails_environment=device_sim node scripts/deploy-to-eb",
    "zip-backend": "mkdir -p .tmp && rm .tmp/deploy.zip &> /dev/null; zip -9 -r --exclude=node_modules/* --exclude=.tmp/* --exclude=.DS_Store --exclude=.git/* --exclude=src/* --exclude=config/local.js ./.tmp/deploy.zip ."
  },
  "main": "app.js",
  "repository": {
    "type": "git",
    "url": "xxxxxxxxxx.git"
  },
  "author": "xxxxxx",
  "license": ""
}

and below is validate-user-password.js

module.exports = {
  friendlyName: 'Validate user password (strict)',
  description: 'Strictly validate a string as the potential "password" for a user.',
  cacheable: true,
  sync: true,
  inputs: {
    string: {
      description: 'The string to validate as a password.',
      required: true,
      example: 'abcd1234',
    }
  },
  exits: {
    success: {
      description: 'The specified string is 100% valid.'
    },
    notValid: {
      description: 'The specified string is not a valid password.'
    },
  },
  fn: function (inputs,exits) {
    // Coerce
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Since we don't need to support `strict: false` for this validator (it is ALWAYS strict), then we can
    // just skip this part.  (Also no need for the "notStrictlyValid" exit, output from the success exit,
    // or the `strict` input)
    //
    // n/a
    // Validate
    //////////////////////////////////////////////////////////////////////////////////////////////////////////

    // • Must be long enough.
    if (inputs.string.length < 7) {
      return exits.notValid(new Error('Password must consist of at least 7 characters.'));
    }

    // • Must not be too long.
    if (inputs.string.length > 72) {
      return exits.notValid(new Error('Password must not contain more than 72 characters.'));
    }

    return exits.success();
  }
};

Indeed, it is probably a update in Sails itself that caused that. Did you try the following configuration for validate-user-password.js ?

module.exports = {
  friendlyName: 'Validate user password (strict)',
  description: 'Strictly validate a string as the potential "password" for a user.',
  sideEffects: 'cacheable',
  sync: true,
  /* ... rest of content ... */
}

I wonder if the issue is related to a change around this time in the version of machine used by Sails core. This normally wouldn't have affected your app unless the semantic version range (SVR) of your Sails dependency was manually increased. But since this app is using a prerelease of Sails v1, it's likely that was the reason this change got picked up downstream.

As @Alexis No mentioned, the solution is to instead of using cacheable: true , to use:

 sideEffects: 'cacheable'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM