slate deploy -e [environment] -m results in `TypeError in plugin 'run-sequence(open:admin)'`
Problem
Today, I encountered a situation where slate deploy -e [environment] -m generates an error in the console for all themes on my production store, and all themes on my development stores. The error occurs across multiple developers' environments and machines and across different networks. The error is always the same:
[15:18:25] Starting 'open:admin'...
[15:18:25] 'open:admin' errored after 4.28 ms
[15:18:25] TypeError: Cannot read property 'store' of undefined
at factory ([theme-root]\node_modules\@shopify\slate-tools\lib\tasks\deploy-utils.js:157:39)
followed by a second error and stack trace:
[15:18:25] 'deploy:manual' errored after 2.91 s
[15:18:25] TypeError in plugin 'run-sequence(open:admin)'
Message:
Cannot read property 'store' of undefined
Stack:
TypeError: Cannot read property 'store' of undefined
at factory ([theme-root]\node_modules\@shopify\slate-tools\lib\tasks\deploy-utils.js:157:39)
Replication steps
Simply passing the -m flag to the slate deploy command will generate the error. Running the deploy command without the flag succeeds, running slate watch succeeds. The error has manifested when updating both published and unpublished themes on at least two shops, one the production Shopify Plus environment the other a Shopify Partner developer environment. The issue is reliably reproducible on both a Windows 10 machine and a Mac OS machine.
More Information
Full stack trace:
[15:18:25] Finished 'build:assets' after 2.52 s
[15:18:25] Finished 'build:zip' after 2.76 s
[15:18:25] Starting 'compress'...
[15:18:25] coordinates-plus.zip 645.42 kB
[15:18:25] Finished 'compress' after 136 ms
[15:18:25] Starting 'output:errors'...
[15:18:25] Finished 'output:errors' after 117 μs
[15:18:25] Finished 'zip' after 2.9 s
[15:18:25] Starting 'open:admin'...
[15:18:25] 'open:admin' errored after 4.28 ms
[15:18:25] TypeError: Cannot read property 'store' of undefined
at factory ([theme-root]\node_modules\@shopify\slate-tools\lib\tasks\deploy-utils.js:157:39)
at [theme-root]\node_modules\@shopify\slate-tools\lib\tasks\includes\utilities.js:62:20
at tryCatcher ([theme-root]\node_modules\bluebird\js\release\util.js:16:23)
at Object.gotValue ([theme-root]\node_modules\bluebird\js\release\reduce.js:155:18)
at Object.gotAccum ([theme-root]\node_modules\bluebird\js\release\reduce.js:144:25)
at Object.tryCatcher ([theme-root]\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler ([theme-root]\node_modules\bluebird\js\release\promise.js:510:31)
at Promise._settlePromise ([theme-root]\node_modules\bluebird\js\release\promise.js:567:18)
at Promise._settlePromiseCtx ([theme-root]\node_modules\bluebird\js\release\promise.js:604:10)
at Async._drainQueue ([theme-root]\node_modules\bluebird\js\release\async.js:143:12)
at Async._drainQueues ([theme-root]\node_modules\bluebird\js\release\async.js:148:10)
at Immediate.Async.drainQueues ([theme-root]\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
[15:18:25] 'deploy:manual' errored after 2.91 s
[15:18:25] TypeError in plugin 'run-sequence(open:admin)'
Message:
Cannot read property 'store' of undefined
Stack:
TypeError: Cannot read property 'store' of undefined
at factory ([theme-root]\node_modules\@shopify\slate-tools\lib\tasks\deploy-utils.js:157:39)
at [theme-root]\node_modules\@shopify\slate-tools\lib\tasks\includes\utilities.js:62:20
at tryCatcher ([theme-root]\node_modules\bluebird\js\release\util.js:16:23)
at Object.gotValue ([theme-root]\node_modules\bluebird\js\release\reduce.js:155:18)
at Object.gotAccum ([theme-root]\node_modules\bluebird\js\release\reduce.js:144:25)
at Object.tryCatcher ([theme-root]\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler ([theme-root]\node_modules\bluebird\js\release\promise.js:510:31)
at Promise._settlePromise ([theme-root]\node_modules\bluebird\js\release\promise.js:567:18)
at Promise._settlePromiseCtx ([theme-root]\node_modules\bluebird\js\release\promise.js:604:10)
at Async._drainQueue ([theme-root]\node_modules\bluebird\js\release\async.js:143:12)
at Async._drainQueues ([theme-root]\node_modules\bluebird\js\release\async.js:148:10)
at Immediate.Async.drainQueues ([theme-root]\node_modules\bluebird\js\release\async.js:17:14) at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
The offending method:
140 /**
141 * Opens the Store in the default browser (for manual upgrade/deployment)
139 *
142 * @function open:admin
143 * @memberof slate-cli.tasks.deploy
144 * @static
145 */
146 gulp.task('open:admin', function () {
147 var file = fs.readFileSync(config.tkConfig, 'utf8');
148 var tkConfig = yaml.safeLoad(file);
149 var envObj = void 0;
150
151 var environments = config.environment.split(/\s*,\s*|\s+/);
152 var promises = [];
153
154 environments.forEach(function (environment) {
155 function factory() {
156 envObj = tkConfig[environment];
157 return open('https://' + envObj.store + '/admin/themes');
158 }
159 promises.push(factory);
160 });
161
162 return utils.promiseSeries(promises);
163 });
My config.yml,
unchanged from the last time a manual deploy was successful. Check that, it has been modified, I have tried deploying with the ignore settings_data.json file both (un)/commented:
# This file contains the information needed for Shopify to authenticate
# requests and edit/update your remote theme files.
#
# 1. Set up a private app (https://help.shopify.com/api/guides/api-credentials#generate-private-app-credentials)
# with "Read and write" permissions for "Theme templates and theme assets".
# 2. Replace the required variables for each environment below.
#
# password, theme_id, and store variables are required.
#
# For more information on this config file:
# Configuration variables | http://shopify.github.io/themekit/configuration/
# Ignore patterns | http://shopify.github.io/themekit/ignores/
---
v0.4.3:
password: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
theme_id: 31985827883
store: live-domain.myshopify.com
ignore_files:
- settings_data.json # Uncomment this line to avoid resetting theme settings
v0.4.3copy:
password: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
theme_id: 31995396139
store: live-domain.myshopify.com
ignore_files:
- settings_data.json # Uncomment this line to avoid resetting theme settings
# this is the partner dev store with the private app name the-coodinator
partner:
password: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
theme_id: 10916069428
store: development-domain.myshopify.com
ignore_files:
#.eslintrc.json
- settings_data.json # Uncomment this line to avoid resetting theme settings
production:
password:
theme_id: "live"
store: live-domain.myshopify.com
ignore_files:
#- settings_data.json # Uncomment this line to avoid resetting theme settings
Final notes:
slate build
slate watch -e [environment]
slate deploy -e [environment]
slate test
all work as expected. I'm left to surmise that there is some error in parsing the store URL out of config.yml when attempting to navigate the browser to the admin so that the user can upload the produced .zip file. Why this would fail to read the store URL for a manual deploy but not for an automated deploy or watch is puzzling.
For reference and contrast here is some code from deploy-sync.js which is reading the same yaml file in nearly the same way
var file = fs.readFileSync(config.tkConfig, 'utf8'); // eslint-disable-line no-sync
var devScript = fs.readFileSync(path.join(__dirname, '/includes/dev-script.js'));
var tkConfig = yaml.safeLoad(file);
var queryStringComponents = [];
var environment = config.environment.split(/\s*,\s*|\s+/)[0];
var envObj = tkConfig[environment];
var proxyTarget = 'https://' + envObj.store;
The bolded line stands out as different.
What has the community got in terms of input?
Hey @ebenwight -- thanks for the incredibly well-written bug report.
I'm going to close this as it is not a critical bug and our priority is now on the next version of Slate, v1.0.0. You should be able to use the slate zip command and manually open the admin as a workaround.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.