Latest deployment to heroku took almost an hour

Need help!

Our app size is 324mb. We deploy to heroku with this build pack. Meteor release is 2.10.
Deployment time has slowly increased. Now build fails often with message:

-----> Building Meteor app with ROOT_URL (secret)
-----> Timed out running buildpack Node.js
! Timed out compiling app (25 minutes)

npm dependencies

"dependencies": {
    "@apollo/client": "^3.6.9",
    "@babel/runtime": "^7.17.9",
    "@emotion/react": "^11.10.5",
    "@emotion/styled": "^11.10.5",
    "@graphql-tools/schema": "^8.5.1",
    "@mui/icons-material": "^5.11.0",
    "@mui/lab": "^5.0.0-alpha.112",
    "@mui/material": "^5.11.0",
    "@mui/styles": "^5.11.0",
    "@mui/x-date-pickers": "^5.0.11",
    "@sentry/node": "^6.19.7",
    "@sentry/react": "^6.19.7",
    "@sentry/tracing": "^6.19.7",
    "apollo-server-express": "^3.6.7",
    "aws-sdk": "^2.1128.0",
    "b64-to-blob": "^1.2.19",
    "babel-plugin-styled-components": "^2.0.7",
    "base64-stream": "^1.0.0",
    "bcrypt": "^5.0.1",
    "chart.js": "^3.8.2",
    "chartjs-plugin-datalabels": "^2.1.0",
    "downloadjs": "^1.4.7",
    "express": "^4.18.1",
    "fast-xml-parser": "^3.21.1",
    "graphql": "^15.8.0",
    "graphql-subscriptions": "^1.2.1",
    "graphql-ws": "^5.9.1",
    "handlebars": "^4.7.7",
    "helmet": "^4.6.0",
    "jsonwebtoken": "^9.0.0",
    "juice": "^8.0.0",
    "lodash": "4.17.21",
    "meteor-accounts-t9n": "^2.6.0",
    "meteor-node-stubs": "^1.2.3",
    "moment": "^2.29.4",
    "moment-timezone": "^0.5.37",
    "node-cron": "^3.0.0",
    "pdfkit": "^0.13.0",
    "pdfkit-table": "^0.1.89",
    "prop-types": "^15.8.1",
    "react": "^17.0.2",
    "react-bootstrap": "^1.6.4",
    "react-chartjs-2": "^4.3.1",
    "react-dom": "^17.0.2",
    "react-dropzone": "^11.7.1",
    "react-joyride": "^2.4.0",
    "react-markdown": "^7.1.2",
    "react-router": "^5.3.1",
    "react-router-dom": "^5.3.1",
    "styled-components": "^5.3.5",
    "twilio": "^3.84.1",
    "ws": "^8.8.1",
    "xlsx": "^0.18.5",
    "xml": "^1.0.1"
  },
  "devDependencies": {
    "@babel/cli": "^7.19.3",
    "@babel/core": "^7.17.10",
    "@babel/eslint-parser": "^7.17.0",
    "@babel/helper-compilation-targets": "^7.17.10",
    "@babel/plugin-transform-runtime": "^7.17.10",
    "@babel/preset-env": "^7.20.2",
    "@babel/preset-react": "^7.16.7",
    "@meteorjs/eslint-config-meteor": "^1.0.5",
    "@testing-library/react": "^12.1.5",
    "@tsconfig/recommended": "^1.0.1",
    "@types/jest": "^27.5.1",
    "@types/jsonwebtoken": "^8.5.8",
    "@types/lodash": "^4.14.182",
    "@types/meteor": "^1.4.87",
    "@types/react": "^17.0.44",
    "@types/react-router-dom": "^5.3.3",
    "@types/styled-components": "^5.1.25",
    "@types/ws": "^8.5.3",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "babel-jest": "^27.5.1",
    "babel-plugin-graphql-tag": "^3.3.0",
    "babel-plugin-import-graphql": "^2.8.1",
    "babel-plugin-lodash": "^3.3.4",
    "cypress": "^11.1.0",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-prettier": "^8.5.0",
    "eslint-import-resolver-meteor": "^0.4.0",
    "eslint-plugin-cypress": "^2.12.1",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-meteor": "^7.3.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.29.4",
    "eslint-plugin-react-hooks": "^4.5.0",
    "husky": "^7.0.4",
    "jest": "^27.5.1",
    "jest-cli": "^27.5.1",
    "lint-staged": "^11.2.6",
    "mongo-seeding": "^3.7.2",
    "prettier": "^2.6.2",
    "react-test-renderer": "^18.1.0",
    "ts-jest": "^28.0.2",
    "typescript": "^4.6.4"
  }

meteor packages

meteor-base@1.5.1             # Packages every Meteor app needs to have
mobile-experience@1.1.0       # Packages for a great mobile UX
mongo@1.16.4                   # The database Meteor supports right now
reactive-var@1.0.12            # Reactive variable for tracker
tracker@1.3.0                 # Meteor's client-side reactive programming library

standard-minifier-css@1.8.3   # CSS minifier run for production mode
standard-minifier-js@2.8.1    # JS minifier run for production mode
es5-shim@4.8.0                # ECMAScript 5 compatibility for older browsers.
ecmascript@0.16.5              # Enable ECMAScript2015+ syntax in app code
shell-server@0.5.0            # Server-side component of the `meteor shell` command

alanning:roles
accounts-base@2.2.6
accounts-password@2.3.3
service-configuration@1.3.1
fortawesome:fontawesome
audit-argument-checks@1.0.7
ddp-rate-limiter@1.1.1
dynamic-import@0.7.2
static-html@1.3.2
server-render@0.4.1
meteorhacks:picker
apollo
swydo:graphql
fourseven:scss
react-meteor-data
accounts-google@1.4.0
force-ssl@1.1.0

hot-module-replacement@0.5.2
typescript@4.7.4

Output of heroku builds -a shows how time has increased lately

Created At                             Duration  Status     
─────────────────────────────────────  ────────  ─────────  
2023/02/07 12:38:10 +0200 (~ 12m ago)            pending    
2023/02/07 11:50:57 +0200 (~ 1h ago)   57m 25s   succeeded  
2023/01/31 03:37:11 +0200              27m 49s   failed     
2023/01/31 02:47:59 +0200              49m 3s    failed     
2023/01/20 02:47:24 +0200              42m 16s   succeeded  
2023/01/19 09:46:17 +0200              33m 7s    succeeded  
2023/01/19 02:47:40 +0200              30m 10s   succeeded  
2023/01/17 02:47:47 +0200              31m 39s   succeeded  
2023/01/14 02:47:16 +0200              31m 56s   succeeded  
2023/01/13 02:48:04 +0200              36m 50s   succeeded  
2023/01/03 02:47:25 +0200              27m 36s   succeeded  
2022/12/30 02:47:43 +0200              28m 19s   succeeded  
2022/12/29 02:47:28 +0200              28m 31s   succeeded  
2022/12/23 02:47:29 +0200              27m 47s   succeeded  
2022/12/21 10:49:07 +0200              28m 14s   succeeded  

Surely something can be done, any tips how to proceed?

What changes were applied to your codebase at Jan 19th? I would start looking there.

Also, run your deploy with METEOR_PROFILE=1 so you can get all the stats about Meteor build.

2 Likes

Here is some profile stuff. Profile logs donΒ΄t show when deploying to heroku, so these are from locally hosted. I will check Jan 19th :slight_smile:


METEOR_PROFILE=100 npm run dev-staging

> 2.1.0 dev-staging
> export $(cat .env.development | xargs) && meteor --settings settings-development.json


| (#1) Profiling: ProjectContext resolveConstraints
|  Selecting package versions                \
| ProjectContext resolveConstraints.............................1,119 ms (1)
| └─ _resolveConstraints........................................1,116 ms (1)
|    β”œβ”€ bundler.readJsImage.......................................287 ms (1)
|    β”‚  └─ meteorNpm.rebuildIfNonPortable.........................256 ms (16)
|    β”‚     └─ meteorNpm.isPortable                                185 ms (314)
|    └─ JsImage#load..............................................802 ms (1)
|       β”œβ”€ runJavaScript packages/dynamic-import.js...............169 ms (1)
|       β”‚  └─ require("/node_modules/meteor/dynamic-import/server.js").168 ms (1)
|       β”‚     └─ require("./security.js")                         166 ms (1)
|       └─ runJavaScript packages/npm-mongo.js....................232 ms (1)
|          └─ Npm.require("mongodb")                              232 ms (1)
| 
| Top leaves:
| require("./security.js")...................................166 ms (1)
| 
| (#1) Total: 1,119 ms (ProjectContext resolveConstraints)
|                       

=> Started proxy.                             
=> Started HMR server.                        
| (#2) Profiling: ProjectContext prepareProjectForBuild
|  Building local packages                   \
| ProjectContext prepareProjectForBuild.........................2,133 ms (1)
| └─ _buildLocalPackages........................................2,053 ms (1)
|    β”œβ”€ _ensurePackageLoaded(accounts-base).......................635 ms (1)
|    β”‚  β”œβ”€ _ensurePackageLoaded(ecmascript).......................332 ms (1)
|    β”‚  β”‚  β”œβ”€ IsopackCache Load local isopack.....................160 ms (1)
|    β”‚  β”‚  β”‚  └─ Isopack#initFromPath.............................160 ms (1)
|    β”‚  β”‚  β”‚     └─ bundler.readJsImage...........................159 ms (1)
|    β”‚  β”‚  β”‚        └─ meteorNpm.rebuildIfNonPortable.............153 ms (8)
|    β”‚  β”‚  β”‚           └─ meteorNpm.isPortable                    111 ms (200)
|    β”‚  β”‚  └─ _ensurePackageLoaded(babel-compiler)................150 ms (1)
|    β”‚  β”‚     └─ IsopackCache Load local isopack..................115 ms (1)
|    β”‚  β”‚        └─ Isopack#initFromPath..........................114 ms (1)
|    β”‚  β”‚           └─ meteorNpm.rebuildIfNonPortable             113 ms (1)
|    β”‚  β”œβ”€ _ensurePackageLoaded(ddp)                              135 ms (1)
|    β”‚  └─ _ensurePackageLoaded(mongo)                            102 ms (1)
|    β”œβ”€ _ensurePackageLoaded(fortawesome:fontawesome).............150 ms (1)
|    β”‚  └─ IsopackCache Load local isopack........................150 ms (1)
|    β”‚     └─ Isopack#initFromPath................................150 ms (1)
|    β”‚        └─ meteorNpm.rebuildIfNonPortable...................139 ms (1)
|    β”‚           └─ meteorNpm.isPortable                          105 ms (272)
|    β”œβ”€ _ensurePackageLoaded(fourseven:scss)......................239 ms (1)
|    β”‚  └─ IsopackCache Load local isopack........................239 ms (1)
|    β”‚     └─ Isopack#initFromPath................................238 ms (1)
|    β”‚        └─ bundler.readJsImage..............................237 ms (1)
|    β”‚           └─ meteorNpm.rebuildIfNonPortable................229 ms (11)
|    β”‚              └─ meteorNpm.isPortable                       173 ms (370)
|    β”œβ”€ _ensurePackageLoaded(react-meteor-data)...................128 ms (1)
|    β”‚  └─ _ensurePackageLoaded(typescript).......................120 ms (1)
|    β”‚     └─ IsopackCache Load local isopack.....................120 ms (1)
|    β”‚        └─ Isopack#initFromPath.............................120 ms (1)
|    β”‚           └─ bundler.readJsImage...........................119 ms (1)
|    β”‚              └─ meteorNpm.rebuildIfNonPortable             115 ms (8)
|    β”œβ”€ _ensurePackageLoaded(standard-minifier-css)...............212 ms (1)
|    β”‚  └─ IsopackCache Load local isopack........................212 ms (1)
|    β”‚     └─ Isopack#initFromPath................................212 ms (1)
|    β”‚        └─ bundler.readJsImage..............................211 ms (1)
|    β”‚           └─ meteorNpm.rebuildIfNonPortable................203 ms (12)
|    β”‚              └─ meteorNpm.isPortable                       151 ms (371)
|    β”œβ”€ _ensurePackageLoaded(standard-minifier-js)................136 ms (1)
|    β”‚  └─ IsopackCache Load local isopack........................136 ms (1)
|    β”‚     └─ Isopack#initFromPath................................136 ms (1)
|    β”‚        └─ bundler.readJsImage..............................135 ms (1)
|    β”‚           └─ meteorNpm.rebuildIfNonPortable                130 ms (12)
|    └─ _ensurePackageLoaded(static-html).........................135 ms (1)
|       └─ IsopackCache Load local isopack........................135 ms (1)
|          └─ Isopack#initFromPath................................135 ms (1)
|             └─ bundler.readJsImage..............................134 ms (1)
|                └─ meteorNpm.rebuildIfNonPortable                112 ms (13)
| 
| Top leaves:
| files.stat.................................................658 ms (11713)
| files.readFile.............................................287 ms (3511)
| files.read.................................................159 ms (1575)
| files.watchFile............................................124 ms (5717)
| 
| (#2) Total: 2,133 ms (ProjectContext prepareProjectForBuild)
| 
| (#3) Profiling: Build App                  /
|  Starting your app                         |
| files.stat                                                        0 ms (1)
| files.readFile                                                    0 ms (1)
| Build App....................................................81,794 ms (1)
| └─ bundler.bundle............................................81,794 ms (1)
|    β”œβ”€ compiler.compile(the app)...............................9,142 ms (1)
|    β”‚  └─ compileUnibuild (the app)............................9,141 ms (3)
|    β”‚     β”œβ”€ Isopack#ensurePluginsInitialized..................1,441 ms (54)
|    β”‚     β”‚  └─ JsImage#load...................................1,437 ms (8)
|    β”‚     β”‚     β”œβ”€ runJavaScript packages/modules.js.............144 ms (7)
|    β”‚     β”‚     β”‚  └─ require("/node_modules/meteor/modules/server.js").141 ms (7)
|    β”‚     β”‚     β”‚     └─ require("./reify.js")...................136 ms (7)
|    β”‚     β”‚     β”‚        └─ require("@meteorjs/reify/lib/runtime") 101 ms (4)
|    β”‚     β”‚     β”œβ”€ runJavaScript packages/react-fast-refresh.js..160 ms (7)
|    β”‚     β”‚     β”‚  └─ require("/node_modules/meteor/react-fast-refresh/server.js") 159 ms (7)
|    β”‚     β”‚     β”œβ”€ runJavaScript packages/fetch.js...............150 ms (5)
|    β”‚     β”‚     β”‚  └─ require("/node_modules/meteor/fetch/server.js").150 ms (5)
|    β”‚     β”‚     β”‚     └─ require("node-fetch")                   149 ms (5)
|    β”‚     β”‚     β”œβ”€ runJavaScript packages/minifier-css.js........221 ms (1)
|    β”‚     β”‚     β”‚  └─ require("/node_modules/meteor/minifier-css/minifier.js").213 ms (1)
|    β”‚     β”‚     β”‚     └─ require("/node_modules/meteor/minifier-css/node_modules/cssnano/dist/index.js") 187 ms (1)
|    β”‚     β”‚     └─ runJavaScript packages/compileScssBatch_plugin.js.232 ms (1)
|    β”‚     β”‚        └─ require("/node_modules/meteor/compileScssBatch/plugin/compile-scss.js").229 ms (1)
|    β”‚     β”‚           └─ require("/node_modules/meteor/compileScssBatch/node_modules/node-sass/lib/index.js") 227 ms (1)
|    β”‚     β”œβ”€ PackageSource#_findSources for os.................2,366 ms (1)
|    β”‚     β”‚  β”œβ”€ _realpath                                        150 ms (5959)
|    β”‚     β”‚  β”œβ”€ files.readdirWithTypes                           306 ms (11914)
|    β”‚     β”‚  β”œβ”€ optimistic readJsonOrNull........................892 ms (5720)
|    β”‚     β”‚  β”‚  β”œβ”€ safeWatcher.watch                             145 ms (10036)
|    β”‚     β”‚  β”‚  β”œβ”€ optimistic readFile...........................589 ms (5720)
|    β”‚     β”‚  β”‚  β”‚  └─ files.readFile                             576 ms (5720)
|    β”‚     β”‚  β”‚  └─ other optimistic readJsonOrNull               158 ms
|    β”‚     β”‚  β”œβ”€ shouldWatch                                      169 ms (5720)
|    β”‚     β”‚  └─ other PackageSource#_findSources for os          764 ms
|    β”‚     β”œβ”€ optimistic hashOrNull.............................1,203 ms (21475)
|    β”‚     β”‚  β”œβ”€ optimistic readFile..............................668 ms (21475)
|    β”‚     β”‚  β”‚  └─ files.readFile                                628 ms (21475)
|    β”‚     β”‚  β”œβ”€ sha1                                             344 ms (21475)
|    β”‚     β”‚  └─ other optimistic hashOrNull                      178 ms
|    β”‚     β”œβ”€ shouldWatch                                         169 ms (21475)
|    β”‚     β”œβ”€ optimistic readFile...............................1,407 ms (21475)
|    β”‚     β”‚  └─ files.readFile                                 1,371 ms (21475)
|    β”‚     β”œβ”€ PackageSource#_findSources for web.browser          313 ms (1)
|    β”‚     └─ other compileUnibuild (the app)                   2,137 ms
|    β”œβ”€ bundler.bundle..makeClientTarget.......................67,637 ms (2)
|    β”‚  └─ Target#make.........................................67,636 ms (2)
|    β”‚     β”œβ”€ Target#_runCompilerPlugins..........................392 ms (2)
|    β”‚     β”‚  └─ plugin static-html                               146 ms (2)
|    β”‚     β”œβ”€ Target#_emitResources............................66,667 ms (2)
|    β”‚     β”‚  β”œβ”€ PackageSourceBatch.computeJsOutputFilesMap....64,753 ms (2)
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#realPath                        336 ms (4202)
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanImports for ecmascript-runtime-client.452 ms (2)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#findImportedModuleIdentifiers 128 ms (397)
|    β”‚     β”‚  β”‚  β”‚  └─ ImportScanner#resolve                      212 ms (1333)
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanImports for base64..........778 ms (2)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ Npm.require("@meteorjs/babel")             290 ms (1)
|    β”‚     β”‚  β”‚  β”‚  └─ other ImportScanner#scanImports for base64 480 ms
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanImports for minimongo       118 ms (2)
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanImports for ddp-client      110 ms (2)
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanImports for url             119 ms (2)
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanImports for the app......61,462 ms (2)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ Babel.compile                            1,715 ms (1559)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#findImportedModuleIdentifiers 18,343 ms (27231)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#resolve...................27,873 ms (102449)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ files.stat                           10,367 ms (73704)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ safeWatcher.watch....................11,007 ms (120790)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  β”œβ”€ files.stat                         8,469 ms (72987)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  β”œβ”€ files.watchFile                    1,370 ms (72987)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  └─ other safeWatcher.watch            1,168 ms
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#addPkgJsonToOutput........215 ms (10166)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  └─ ImportScanner#resolvePkgJsonBrowserAliases 122 ms (894)
|    β”‚     β”‚  β”‚  β”‚  β”‚  └─ other ImportScanner#resolve           6,203 ms
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#getAbsModuleId               433 ms (25624)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#realPath...................3,238 ms (25624)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ safeWatcher.watch                       110 ms (52164)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ optimistic lstat........................631 ms (25902)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  └─ files.lstat                          561 ms (25902)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ shouldWatch                             379 ms (25902)
|    β”‚     β”‚  β”‚  β”‚  β”‚  └─ other ImportScanner#realPath          2,119 ms
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#readFile...................4,329 ms (25626)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ optimistic readFile...................1,615 ms (24871)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  └─ files.readFile                     1,544 ms (24871)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ optimistic hashOrNull.................1,278 ms (24871)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  β”œβ”€ optimistic readFile..................656 ms (24871)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  β”‚  └─ files.readFile                    601 ms (24871)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  β”œβ”€ sha1                                 273 ms (24871)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  └─ other optimistic hashOrNull          305 ms
|    β”‚     β”‚  β”‚  β”‚  β”‚  └─ other ImportScanner#readFile          1,352 ms
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ DefaultHandlers.js.......................2,165 ms (25612)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”œβ”€ reifyCompileWithCache.................1,900 ms (25612)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  β”œβ”€ files.readFile                     1,580 ms (25449)
|    β”‚     β”‚  β”‚  β”‚  β”‚  β”‚  └─ other reifyCompileWithCache          320 ms
|    β”‚     β”‚  β”‚  β”‚  β”‚  └─ other DefaultHandlers.js                265 ms
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ Npm.require("@meteorjs/babel")             211 ms (1)
|    β”‚     β”‚  β”‚  β”‚  └─ other ImportScanner#scanImports for the app 3,078 ms
|    β”‚     β”‚  β”‚  β”œβ”€ ImportScanner#scanMissingModules for apollo...471 ms (2)
|    β”‚     β”‚  β”‚  β”‚  β”œβ”€ ImportScanner#resolve                      168 ms (350)
|    β”‚     β”‚  β”‚  β”‚  └─ ImportScanner#findImportedModuleIdentifiers 213 ms (137)
|    β”‚     β”‚  β”‚  └─ other PackageSourceBatch.computeJsOutputFilesMap 150 ms
|    β”‚     β”‚  β”œβ”€ PackageSourceBatch#getResources................1,787 ms (148)
|    β”‚     β”‚  β”‚  └─ PackageSourceBatch#_linkJS..................1,781 ms (148)
|    β”‚     β”‚  β”‚     β”œβ”€ files.readFile                             713 ms (148)
|    β”‚     β”‚  β”‚     └─ other PackageSourceBatch#_linkJS         1,034 ms
|    β”‚     β”‚  └─ other Target#_emitResources                      121 ms
|    β”‚     β”œβ”€ Target#minifyJs.....................................116 ms (2)
|    β”‚     β”‚  └─ sha512                                           113 ms (150)
|    β”‚     β”œβ”€ ClientTarget#minifyCss                              274 ms (2)
|    β”‚     └─ sha512                                              160 ms (158)
|    β”œβ”€ bundler.bundle..makeServerTarget........................2,036 ms (1)
|    β”‚  └─ Target#make..........................................2,036 ms (1)
|    β”‚     └─ Target#_emitResources.............................1,944 ms (1)
|    β”‚        └─ PackageSourceBatch.computeJsOutputFilesMap.....1,847 ms (1)
|    β”‚           β”œβ”€ ImportScanner#realPath                        112 ms (2155)
|    β”‚           └─ ImportScanner#scanImports for the app.......1,088 ms (1)
|    β”‚              β”œβ”€ Babel.compile                              183 ms (218)
|    β”‚              β”œβ”€ ImportScanner#findImportedModuleIdentifiers 413 ms (298)
|    β”‚              └─ ImportScanner#resolve......................347 ms (1055)
|    β”‚                 β”œβ”€ files.stat                              122 ms (1047)
|    β”‚                 └─ safeWatcher.watch.......................128 ms (1777)
|    β”‚                    └─ files.stat                           104 ms (871)
|    └─ bundler writeSiteArchive................................2,885 ms (1)
|       β”œβ”€ bundler writeTargetToPath............................2,292 ms (3)
|       β”‚  β”œβ”€ ClientTarget#write..................................825 ms (2)
|       β”‚  β”‚  β”œβ”€ bundler writeFile................................655 ms (362)
|       β”‚  β”‚  β”‚  β”œβ”€ Builder#write                                 104 ms (362)
|       β”‚  β”‚  β”‚  └─ other bundler writeFile                       552 ms
|       β”‚  β”‚  └─ other ClientTarget#write                         133 ms
|       β”‚  └─ ServerTarget#write................................1,462 ms (1)
|       β”‚     └─ JsImage#write..................................1,445 ms (1)
|       β”‚        β”œβ”€ files.stat                                    346 ms (3709)
|       β”‚        β”œβ”€ Builder#copyNodeModulesDirectory              402 ms (30)
|       β”‚        β”œβ”€ safeWatcher.watch.............................424 ms (6125)
|       β”‚        β”‚  └─ files.stat                                 331 ms (3551)
|       β”‚        └─ other JsImage#write                           223 ms
|       └─ other bundler writeSiteArchive                         589 ms
| 
| Top leaves:
| files.stat..............................................20,741 ms (174123)
| files.readFile...........................................7,321 ms (127573)
| other ImportScanner#resolve..............................6,290 ms (103504)
| other ImportScanner#scanImports for the app..............3,175 ms (3)
| other compileUnibuild (the app)..........................2,137 ms (3)
| Babel.compile............................................2,131 ms (2037)
| other ImportScanner#realPath.............................2,119 ms (25624)
| files.watchFile..........................................1,665 ms (89838)
| other ImportScanner#readFile.............................1,352 ms (25626)
| other safeWatcher.watch..................................1,228 ms (128692)
| other PackageSourceBatch#_linkJS.........................1,034 ms (148)
| other PackageSource#_findSources for os....................764 ms (1)
| sha1.......................................................757 ms (54677)
| files.lstat................................................746 ms (43885)
| other bundler writeSiteArchive.............................589 ms (1)
| other bundler writeFile....................................552 ms (362)
| ImportScanner#getAbsModuleId...............................523 ms (33991)
| other optimistic hashOrNull................................483 ms (46346)
| other ImportScanner#scanImports for base64.................480 ms (2)
| files.readdirWithTypes.....................................333 ms (24390)
| other reifyCompileWithCache................................320 ms (25612)
| sha512.....................................................283 ms (342)
| other DefaultHandlers.js...................................265 ms (25612)
| other JsImage#write........................................223 ms (1)
| other optimistic readFile..................................215 ms (98412)
| other PackageSourceBatch.computeJsOutputFilesMap...........196 ms (3)
| shouldWatch................................................177 ms (22982)
| other optimistic readJsonOrNull............................158 ms (5720)
| safeWatcher.watch..........................................156 ms (100767)
| other Target#_emitResources................................153 ms (3)
| other ClientTarget#write...................................133 ms (2)
| files.writeFile............................................132 ms (693)
| 
| (#3) Total: 81,794 ms (Build App)
| 
 (#1) Profiling: Server startup
 Server startup................................................8,554 ms (1)
 secrets :)
 (#1) Total: 8,554 ms (Server startup)
1 Like

That is a huge app. Are you making sure that you are deploying without dev dependencies?

meteor npm prune --production
1 Like

I thought its too big, need to investigate this. Thx!

1 Like

Seems like dev dependencies are installed. :dotted_line_face:
Im trying different buildpack if it would fix this, since updating current one dosent seem to work…

Im little bit confused about this babel stuff - is it encouraged to use as little as possible plugins in meteor project?

{
  "plugins": [
    "babel-plugin-lodash",
    [
      "babel-plugin-styled-components",
      {
        "ssr": false
      }
    ]
  ],
  "presets": [
    ["@babel/preset-react"],
    ["@babel/preset-env", { "targets": { "node": "current" } }],
    "@babel/preset-typescript"
  ]
}

We have many babel plugins installed as devDependencies.

If you run my command before deploy and don’t have any other npm install scripts in your deploy code then that should remove the dev dependencies from deployed bundle.

I haven’t done this before, so would this my custom deployment script look something like this?

meteor npm install --production
meteor npm prune --production
meteor build /path/to/build --architecture os.linux.x86_64
cd my_build_bundle_directory
(cd programs/server && npm install) <- from documentation, you said  no more npm scripts, so ignore this line?
MONGO_URL=... ROOT_URL=... PORT=... node main.js

We are currently using this buildpack, but slighty modified.
meteor npm install is called twice here. Can someone more experienced explain why?
If I would continue using this buildpack, where would you put npm prune command and what npm installs would you remove?

Putting npm prune before the first npm install causes the next error

emote: -----> Target Meteor version: Meteor 2.10.0
remote: -----> Checking if this meteor version supports --server-only
remote: -----> Using node: v14.21.2
remote: ----->    and npm: 6.14.17
remote: 
remote: > bcrypt@5.1.0 install node_modules/bcrypt
remote: > node-pre-gyp install --fallback-to-build
remote: 
remote: sh: 1: node-pre-gyp: not found
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! syscall spawn
remote: npm ERR! file sh
remote: npm ERR! errno ENOENT
remote: npm ERR! bcrypt@5.1.0 install: `node-pre-gyp install --fallback-to-build`
remote: npm ERR! spawn ENOENT
remote: npm ERR! 
remote: npm ERR! Failed at the bcrypt@5.1.0 install script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: 
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /app/.npm/_logs/2023-02-14T10_56_34_908Z-debug.log
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...

And after it has no effect to app size / deployment time.

1 Like

Btw tried to deploy to Scalingo, there our app deployed in 11 minutes, but size was whopping 694 MB! Their buildpack.