ember-cli / ember-compatibility-helpers

Helpers that allow you to write backwards compat Ember addons
MIT License
24 stars 20 forks source link

Latest version failed with error `Cannot read property 'match' of undefined` #47

Closed VelDeveloper closed 3 years ago

VelDeveloper commented 3 years ago

Hi Guys,

I am using ember application 2.13.0. The application was working fine 2-weeks ago today I run the same build and end up with below error,

TypeError: Cannot read property 'match' of undefined
    at extractTrueVersion (/Users/dev/content-book/node_modules/ember-compatibility-helpers/utils/extract-true-version.js:11:54)
    at Class._getComparisonPlugin (/Users/dev/content-book/node_modules/ember-compatibility-helpers/index.js:71:30)
    at Class.registerTransformWithParent (/Users/dev/content-book/node_modules/ember-compatibility-helpers/index.js:52:35)
    at Class.included (/Users/dev/content-book/node_modules/ember-compatibility-helpers/index.js:35:10)
    at Class.superWrapper [as included] (/Users/dev/content-book/node_modules/ember-cli/node_modules/core-object/lib/assign-properties.js:34:20)
    at addons.map.addon (/Users/dev/content-book/node_modules/ember-cli/lib/models/addon.js:352:34)
    at Array.map (<anonymous>)
    at Class.eachAddonInvoke (/Users/dev/content-book/node_modules/ember-cli/lib/models/addon.js:350:24)
    at Class.included (/Users/dev/content-book/node_modules/ember-cli/lib/models/addon.js:621:10)
    at Class.superWrapper [as included] (/Users/dev/content-book/node_modules/ember-cli/node_modules/core-object/lib/assign-properties.js:34:20)

Just re-building the application which was working 2-weeks ago failed with the above exception. The only change I see is NPM pulled the latest version of ember-compatibility-helpers which broke the pipeline.

I also removed the package-lock.json and node_modules but no luck. I couldn't fall back to the older version of the library because this library was pulled from one of the transitive dependency libraries.

Any help would be really appreciable.

bantic commented 3 years ago

@VelDeveloper In your app, are you installing ember from bower? The issue we ran into is that we use bower for ember (for ember versions 2.4 and 2.8), and this change which was added in v1.2.2 of ember-compatibility-helpers assumes that the 'ember-source' package will be present:

https://github.com/pzuraq/ember-compatibility-helpers/blob/03c8282316f41c7e42d0e828b1d5e185fc8c8661/index.js#L17

Our fix was to use a resolution to ensure that ember-compatibility-helpers v1.2.1 is installed. E.g. in package.json add:

...
resolutions: {
  'ember-compatibility-helpers': '1.2.1'
}
VelDeveloper commented 3 years ago

@bantic Thanks a lot for your reply. Yes I did the same and it worked fine. For some reason my project gitlab pipeline is still failing and it picks 1.2.2 even though I see 1.2.1 in package.json. This is may be caching of node_modules? do we need to remove node_modules for this change should be happen?

Please find the package.json and bower.json for your reference. Yes we are installing Ember from bower. I also added "preinstall": "npx npm-force-resolutions", for this version change should happen.

Note : I am not using yarn so we are using npm-force-resolutions package to make the resolutions work.

Package.json

{
  "name": "book-content",
  "version": "0.0.0",
  "description": "content book portal",
  "private": true,
  "directories": {
    "doc": "doc",
    "test": "tests"
  },
  "scripts": {
    "preinstall": "npx npm-force-resolutions",
    "build": "ember build",
    "start": "ember server",
    "test": "ember test"
  },
  "repository": "",
  "engines": {
    "node": ">= 0.10.0"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {
    "broccoli-asset-rev": "^2.2.0",
    "broccoli-funnel": "^1.0.2",
    "broccoli-merge-trees": "^1.1.1",
    "bson": "^4.0.4",
    "ember-ajax": "0.7.1",
    "ember-aupac-typeahead": "3.1.0",
    "ember-browserify": "^1.2.2",
    "ember-can": "^0.8.1",
    "ember-cli": "2.13.0",
    "ember-cli-app-version": "^1.0.0",
    "ember-cli-autocomplete-input": "1.1.0",
    "ember-cli-babel": "^5.1.5",
    "ember-cli-dependency-checker": "^1.2.0",
    "ember-cli-htmlbars": "^1.0.1",
    "ember-cli-htmlbars-inline-precompile": "^0.3.1",
    "ember-cli-inject-live-reload": "^1.3.1",
    "ember-cli-moment-shim": "^3.7.1",
    "ember-cli-pace": "0.1.0",
    "ember-cli-pagination": "2.2.2",
    "ember-cli-qunit": "^1.2.1",
    "ember-cli-release": "0.2.8",
    "ember-cli-sass": "^7.1.7",
    "ember-cli-sri": "^2.1.0",
    "ember-cli-uglify": "^1.2.0",
    "ember-composable-helpers": "2.1.0",
    "ember-concurrency": "0.8.21",
    "ember-data": "2.7.0",
    "ember-disable-proxy-controllers": "^1.0.1",
    "ember-export-application-global": "^1.0.4",
    "ember-get-helper": "1.1.0",
    "ember-load-initializers": "^0.5.0",
    "ember-lodash": "4.17.1",
    "ember-moment": "^7.8.0",
    "ember-plupload": "1.13.18",
    "ember-power-select-typeahead": "0.7.1",
    "ember-query-params-reset": "2.0.0",
    "ember-resolver": "^2.0.3",
    "ember-rl-month-picker": "^0.2.0",
    "ember-rl-year-picker": "^0.2.0",
    "ember-slide-push-menu": "1.0.0",
    "ember-truth-helpers": "1.2.0",
    "ember-uploader": "1.0.0",
    "ember-validations": "v2.0.0-alpha.5",
    "express": "^4.13.4",
    "glob": "^4.5.3",
    "loader.js": "^4.0.0",
    "morgan": "^1.7.0",
    "uglify-js": "2.7.1"
  },
  "dependencies": {
    "minimist": "^1.2.0"
  },
  "resolutions": {
    "ember-compatibility-helpers": "1.2.1"
  }
}

Bower.json

{
  "name": "io-t-po-c-fulfullment-frontend",
  "dependencies": {
    "ember": "2.7.0",
    "ember-cli-shims": "~0.1.1",
    "ember-cli-test-loader": "0.2.2",
    "ember-qunit-notifications": "0.1.0",
    "pretender": "~0.10.1",
    "lodash": "~3.7.0",
    "Faker": "~3.0.0",
    "datatables": "^1.10.11",
    "bootstrap": "4.0.0-alpha.2",
    "compass-mixins": "^1.0.2",
    "tether": "^1.2.0",
    "font-awesome": "^4.5.0",
    "select2": "^4.0.2",
    "select2-bootstrap-theme": "^0.1.0-beta.4",
    "pace": "^1.0.2",
    "dropzone": "^4.3.0",
    "tinymce": "^4.3.13",
    "moment": "^2.14.1",
    "dinosheets": "0.1.1",
    "plupload": "v2.1.8"
  },
  "resolutions": {
    "bootstrap": "4.0.0-alpha.2"
  }
}
rwjblue commented 3 years ago

Ya, we should update to avoid that assumption (the error being thrown now isn't helpful at all).

VelDeveloper commented 3 years ago

I am not using yarn and my server doesn't have permission to run npx npm-force-resolutions preinstall script. @rwjblue @bantic Do we have any other solution apart from this? I have already raised ticket to GRANT permission to run this script but I have less hope for the permission to be GRANTED.

Any help would be really appreciable.

rwjblue commented 3 years ago

We just need to fix the issue that @bantic pointed out. If ember-source is not found, we have to 1) not error and 2) try to fallback to something usefull.

bantic commented 3 years ago

Yeah — I took a stab at using bower as a fallback for older Ember, but I got stuck when I saw that ember-cli-version-checker dropped bower support in the 5.0 release. I'm not sure how best to add back in a bower fallback here. At minimum we could make a better error message though, I suppose.

VelDeveloper commented 3 years ago

@bantic @rwjblue After this update I couldn't able to navigate to links <link-to> which are using ember-data I believe. Do you guys aware of any such issue recently? you can find package.json and bower.json in the above post. Could you please share your thoughts?

VelDeveloper commented 3 years ago

@bantic @rwjblue After spending lot of time on debugging we found out all the xhr responses are blocked that's the reason we couldn't able to load any data and the links stopped working where as we can able to get data using Fetch. Do you guys faced any weird issue like this?

rwjblue commented 3 years ago

Fixed by #48 and released as 1.2.3