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

Issues Upgrading to 2.X #474

Closed
Emerson opened this issue Dec 8, 2021 · 8 comments
Closed

Issues Upgrading to 2.X #474

Emerson opened this issue Dec 8, 2021 · 8 comments

Comments

@Emerson
Copy link

Emerson commented Dec 8, 2021

Howdy,

We have a four mature applications and are in the process of trying to upgrade ember-auto-import from 1.12.0 to 2.x. Of the four apps, two of them appear to build on 2.x, but the others just error out with Cannot read property 'length' of undefined.

When I get the debug output I see the following:

ENV Summary:

  TIME: Wed Dec 08 2021 16:49:22 GMT-0500 (Eastern Standard Time)
  TITLE: ember
  ARGV:
  - /usr/local/bin/node
  - /usr/local/bin/ember
  - s
  EXEC_PATH: /usr/local/bin/node
  TMPDIR: /var/folders/nj/g97b10ms3vs5tc73z0pntqsw0000gn/T
  SHELL: /bin/zsh
  PATH:
  - /usr/local/bin
  - /usr/bin
  - /bin
  - /usr/sbin
  - /sbin
  PLATFORM: darwin x64
  FREEMEM: 859795456
  TOTALMEM: 34359738368
  UPTIME: 189072
  LOADAVG: 12.484375,10.97705078125,9.80859375
  CPUS:
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  - Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz - 2600
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.17.2
  - brotli: 1.0.9
  - cldr: 39.0
  - icu: 69.1
  - llhttp: 2.1.3
  - modules: 83
  - napi: 8
  - nghttp2: 1.42.0
  - node: 14.17.6
  - openssl: 1.1.1l
  - tz: 2021a
  - unicode: 13.0
  - uv: 1.41.0
  - v8: 8.4.371.23-node.76
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - code: [undefined]
  - codeFrame: [undefined]
  - errorMessage: Cannot read property 'length' of undefined
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Cannot read property 'length' of undefined
  - name: TypeError
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: TypeError: Cannot read property 'length' of undefined
    at ensureTrailingSlash (/Users/emerson/Code/frontend/login/node_modules/ember-auto-import/js/package.js:418:17)
    at Package.publicAssetURL (/Users/emerson/Code/frontend/login/node_modules/ember-auto-import/js/package.js:257:161)
    at AutoImport.makeBundler (/Users/emerson/Code/frontend/login/node_modules/ember-auto-import/js/auto-import.js:104:46)
    at AutoImport.addTo (/Users/emerson/Code/frontend/login/node_modules/ember-auto-import/js/auto-import.js:116:51)
    at Class.postprocessTree (/Users/emerson/Code/frontend/login/node_modules/ember-auto-import/js/index.js:47:55)
    at /Users/emerson/Code/frontend/login/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25
    at Array.reduce (<anonymous>)
    at addonProcessTree (/Users/emerson/Code/frontend/login/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)
    at EmberApp.addonPostprocessTree (/Users/emerson/Code/frontend/login/node_modules/ember-cli/lib/broccoli/ember-app.js:867:12)
    at EmberApp.toTree (/Users/emerson/Code/frontend/login/node_modules/ember-cli/lib/broccoli/ember-app.js:1690:17)

If anyone has any insight into where I can start with debugging this, it would be very appreciated.

@Emerson
Copy link
Author

Emerson commented Dec 9, 2021

So after digging into this for awhile, I was able to determine that the issue is with the @sentry/ember package and you can see it being talked about here

@NullVoxPopuli
Copy link
Contributor

I'm not using @sentry/ember and am seeing this issue. 🤔

similar stack

=================================================================================

ENV Summary:

  TIME: Sat Dec 11 2021 16:15:08 GMT-0500 (Eastern Standard Time)
  TITLE: ember
  ARGV:
  - 🏠/.volta/tools/image/node/16.2.0/bin/node
  - /✂️/ember-statechart-component/testing/ember-app/node_modules/.bin/ember
  - s
  EXEC_PATH: 🏠/.volta/tools/image/node/16.2.0/bin/node
  TMPDIR: /tmp
  SHELL: /bin/bash
  PATH:
  - 🏠/.volta/tools/image/npm/7.7.5/bin
  - 🏠/.volta/tools/image/yarn/1.22.5/bin
  - 🏠/.volta/tools/image/node/16.2.0/bin
  - 🏠/.volta/bin
  - 🏠/.pythons/Python-3.6.3/bin
  - 🏠/.cargo/bin
  - 🏠/Applications
  - 🏠/apps/phantomjs/bin
  - 🏠/scripts/system-utils
  - 🏠/scripts/git
  - 🏠/scripts/rails
  - 🏠/scripts
  - 🏠/.volta/bin
  - 🏠/.local/bin
  - /usr/local/sbin
  - /usr/local/bin
  - /usr/sbin
  - /usr/bin
  - /sbin
  - /bin
  - /usr/games
  - /usr/local/games
  - /snap/bin
  - 🏠/.dotnet/tools
  - 🏠/.dotnet/tools
  - 🏠/.fzf/bin
  PLATFORM: linux x64
  FREEMEM: 1940430848
  TOTALMEM: 17388195840
  UPTIME: 512804.08
  LOADAVG: 0.94,0.55,0.51
  CPUS:
  - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz - 3192
  - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz - 3192
  - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz - 3192
  - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz - 3192
  - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz - 3192
  - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz - 3192
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.17.1
  - brotli: 1.0.9
  - cldr: 39.0
  - icu: 69.1
  - llhttp: 6.0.1
  - modules: 93
  - napi: 8
  - nghttp2: 1.42.0
  - nghttp3: 0.1.0-DEV
  - ngtcp2: 0.1.0-DEV
  - node: 16.2.0
  - openssl: 1.1.1k+quic
  - tz: 2021a
  - unicode: 13.0
  - uv: 1.41.0
  - v8: 9.0.257.25-node.16
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: [undefined]
  - code: [undefined]
  - codeFrame: [undefined]
  - errorMessage: Cannot read property 'length' of undefined
  - errorType: [undefined]
  - location:
    - column: [undefined]
    - file: [undefined]
    - line: [undefined]
  - message: Cannot read property 'length' of undefined
  - name: TypeError
  - nodeAnnotation: [undefined]
  - nodeName: [undefined]
  - originalErrorMessage: [undefined]
  - stack: TypeError: Cannot read property 'length' of undefined
    at ensureTrailingSlash (/✂️/ember-statechart-component/node_modules/ember-auto-import/js/package.js:418:17)
    at Package.publicAssetURL (/✂️/ember-statechart-component/node_modules/ember-auto-import/js/package.js:257:161)
    at AutoImport.makeBundler (/✂️/ember-statechart-component/node_modules/ember-auto-import/js/auto-import.js:104:46)
    at AutoImport.addTo (/✂️/ember-statechart-component/node_modules/ember-auto-import/js/auto-import.js:116:51)
    at Class.postprocessTree (/✂️/ember-statechart-component/node_modules/ember-auto-import/js/index.js:47:55)
    at /✂️/ember-statechart-component/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25
    at Array.reduce (<anonymous>)
    at addonProcessTree (/✂️/ember-statechart-component/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)
    at EmberAddon.addonPostprocessTree (/✂️/ember-statechart-component/node_modules/ember-cli/lib/broccoli/ember-app.js:867:12)
    at EmberAddon.toTree (/✂️/ember-statechart-component/node_modules/ember-cli/lib/broccoli/ember-app.js:1690:17)

=================================================================================

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Dec 11, 2021

this is my fix:

diff --git a/testing/ember-app/ember-cli-build.js b/testing/ember-app/ember-cli-build.js
index 17bd7d6..dafa68a 100644
--- a/testing/ember-app/ember-cli-build.js
+++ b/testing/ember-app/ember-cli-build.js
@@ -1,9 +1,9 @@
 'use strict';
 
-const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
+const EmberApp = require('ember-cli/lib/broccoli/ember-app');
 
 module.exports = function (defaults) {
-  let app = new EmberAddon(defaults, {});
+  let app = new EmberApp(defaults, {});
 

tl;dr: I'm migrating an addon from the v1 format to the new v2 format, and copy-pasted my ember-cli-build without changing the test app from being an EmberAddon to being an EmberApp

@ef4
Copy link
Collaborator

ef4 commented Dec 11, 2021

The stack trace above implies that an app is missing its rootURL. Check your config/environment.js. It should set rootURL to a string.

@Emerson
Copy link
Author

Emerson commented Jan 5, 2022

Hmmm, @ef4 I think you're definitely onto something. Looking at the generated script tags in my HTML source and all our assets have the proper root URL (we're serving from S3), but the ember-auto-import script tag is just pointing to src="/assets/...".

In our ember-cli-build.js file we are using the fingerprint option to prepend our production URLs like this:

// ember-cli-build.js

  switch (env) {
    case "production":
      fingerprint.enabled = true;
      fingerprint.prepend =
        "https://s3.amazonaws.com/our-bucket-name/";
      break;

Maybe we are doing this wrong and should just use the rootUrl option?

@Emerson
Copy link
Author

Emerson commented Jan 5, 2022

Just found this in the Ember-CLI docs:

The rootURL is used as a prefix for assets, e.g. /path/to/ember/app/assets/vendor.js. However when building for production, the value of prepend for fingerprint will be used instead.

@Emerson
Copy link
Author

Emerson commented Jan 5, 2022

Ah, just found:

apps that use fingerprint.prepend to move their assets to a different origin will also need to set autoImport.publicAssetURL. See example below.

🤦

@Emerson
Copy link
Author

Emerson commented Jan 5, 2022

Resolved by setting the publicAssetURL correctly. Feel free to close the issue and sorry for taking up your time.

@Emerson Emerson closed this as completed Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants