I'm splitting this off from the parent issue.
When I go through config.yaml enabling sources and get to v3view, I hit an error
Uncommenting this source causes the error
```
lang=yaml
v3view:
public: true
formats: [png,json,headers,svg,jpeg]
scales: [1.3, 1.5, 2, 2.6, 3]
static: true
maxheight: 2048
maxwidth: 2048
uri: tmstyle://
yaml:
npm: ['@kartotherian/brighmed', "project.yml"]
yamlSetParams:
source: {ref: v3}
```
The error is
```
[2018-06-01T08:43:24.558Z] FATAL: tilerator/14 on maps-test2004: (levelPath=fatal/service-runner/unhandled)
TypeError: Cannot read property 'length' of undefined
at /srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/tilelive-tmstyle/index.js:180:56
at Array.map (native)
at /srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/tilelive-tmstyle/index.js:179:34
at CassandraStore.handler.getInfo (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/@kartotherian/core/lib/sources.js:260:7)
at /srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/tilelive-tmstyle/index.js:118:20
at tryCatcher (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/util.js:16:23)
at Promise.successAdapter (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/nodeify.js:23:30)
at Promise._settlePromise (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/promise.js:566:21)
at Promise._settlePromiseCtx (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/promise.js:606:10)
at Async._drainQueue (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/async.js:138:12)
at Async._drainQueues (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/srv/deployment/tilerator/deploy-cache/revs/9f924d6a3d8d7df882cae49a314efa13bab18186/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
[2018-06-01T08:43:24.685Z] WARN: tilerator/4 on maps-test2004: first worker died during startup, continue startup (message="first worker died during startup, continue startup", worker_pid=14, exit_code=1, startup_attempt=1, levelPath=warn/service-runner/master)
```
The [relevant code](https://github.com/mojodna/tilelive-tmstyle/blob/0936bd4d29f15ed678dc9abf8f4bb1355cae7aae/index.js#L178-L186) is
```
lang=js
//Layer ordering defined in style
opts.Layer = data.layers.map(function(layerId) {
for(var i = 0; i < backend.data.vector_layers.length; i++) {
var layer = backend.data.vector_layers[i];
if(layer.id == layerId) {
return layerToDef(layer);
}
}
});
```
Although tilelive-tmstyle needs better error reporting, the fix isn't just changing something in its code, since it's supposed to be doing something. This section of code is *supposed* to go through the layers the tmstyle calls for and match them up against source layers.
I have some thoughts on approaches for possible fixes and debugging, but I'll post that in a comment to keep it separate.
There are a few monkey patches in place here to get some other things working, which are
To work around {T196124} and get a stack trace
```
lang=diff
--- a/node_modules/service-runner/lib/logger.js
+++ b/node_modules/service-runner/lib/logger.js
@@ -202,7 +202,7 @@ class Logger {
const logUnhandledException = (err) => {
if (!inLogger) {
inLogger = true;
- this.log('fatal/service-runner/unhandled', err);
+ this.log('fatal/service-runner/unhandled', err.stack);
inLogger = false;
}
};
```
To get a tilejson that the .tm2 yaml could point at, which we believed was important
```
lang=diff
--- a/node_modules/@kartotherian/brighmed/project.yml
+++ b/node_modules/@kartotherian/brighmed/project.yml
@@ -22,7 +22,7 @@ format: "png"
minzoom: 0
maxzoom: 19
srs: "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over"
-source: "tmsource:///home/user/path/to/meddo"
+source: "tilejson+file:///srv/deployment/tilerator/deploy/node_modules/@kartotherian/brighmed/tile.json"
styles:
- style.mss
- water.mss
```
```
lang=diff
--- /dev/null
+++ b/node_modules/@kartotherian/brighmed/tile.json
@@ -0,0 +1 @@
+{"tilejson":"2.1.0","center":[-122.4144,37.7907,14],"description":"Data source for Wikimedia's fork of osm-bright2","format":"pbf","vector_layers":[{"id":"
landcover"},{"id":"landuse"},{"id":"waterway"},{"id":"water"},{"id":"pier"},{"id":"building"},{"id":"transport"},{"id":"aeroway"},{"id":"park"},{"id":"bound
ary"},{"id":"country_name"},{"id":"place"},{"id":"state_name"},{"id":"transport_name"},{"id":"landcover_name"},{"id":"transit_stop"}],"maxzoom":14,"minzoom"
:0,"name":"osm-pbf","attribution":"<a href=\"https://wikimediafoundation.org/wiki/Maps_Terms_of_Use\">Wikimedia maps</a> | Map data © <a href=\"http://
openstreetmap.org/copyright\">OpenStreetMap contributors</a>","tiles":["https://maps.wikimedia.org/osm-pbf/{z}/{x}/{y}.pbf"]}
```
To disable sources to identify the problem, all sources after `v3view` were commented out