@things-factory/integration-base 8.0.90 → 8.0.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-base",
3
- "version": "8.0.90",
3
+ "version": "8.0.92",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -44,5 +44,5 @@
44
44
  "readline": "^1.3.0",
45
45
  "ses": "^1.5.0"
46
46
  },
47
- "gitHead": "196118cd2941406d5927e6fe3558a9a8b0623df0"
47
+ "gitHead": "7f6ea0914d9117e9fe4ca3fff64a8a0faedb616f"
48
48
  }
@@ -130,9 +130,10 @@ export class OperatoConnector implements Connector {
130
130
  })
131
131
 
132
132
  const subscriptions: SubscriberData[] = []
133
- Object.keys(subscriptionHandlers).forEach(async tag => {
134
- if (!tag || !subscriptionHandlers[tag]) return
133
+ const tags = Object.keys(subscriptionHandlers).filter(tag => tag && subscriptionHandlers[tag])
135
134
 
135
+ /* 시나리오 조회 및 subscription 등록을 순차적으로 처리 */
136
+ for (const tag of tags) {
136
137
  const scenarioName = subscriptionHandlers[tag]
137
138
 
138
139
  // fetch a scenario
@@ -143,6 +144,14 @@ export class OperatoConnector implements Connector {
143
144
  relations: ['steps', 'domain']
144
145
  })
145
146
 
147
+ /* 시나리오가 DB에 없으면 경고 로그를 남기고 건너뜀 */
148
+ if (!selectedScenario) {
149
+ ConnectionManager.logger.warn(
150
+ `(${connection.name}) scenario not found for tag "${tag}" (scenarioName: "${scenarioName}") - skipping subscription`
151
+ )
152
+ continue
153
+ }
154
+
146
155
  const subscription = client.subscribe({
147
156
  query: gql`
148
157
  subscription {
@@ -156,8 +165,13 @@ export class OperatoConnector implements Connector {
156
165
 
157
166
  const subscriptionObserver = subscription.subscribe({
158
167
  next: async data => {
159
- debug('received pubsub msg.:', data?.data)
160
- await this.runScenario(subscriptions, data?.data?.data)
168
+ /* subscription 수신 시 에러가 발생해도 프로세스가 죽지 않도록 catch 처리 */
169
+ try {
170
+ debug('received pubsub msg.:', data?.data)
171
+ await this.runScenario(subscriptions, data?.data?.data)
172
+ } catch (e) {
173
+ ConnectionManager.logger.error(`(${connection.name}:${tag}) runScenario failed`, e)
174
+ }
161
175
  },
162
176
  error: error => {
163
177
  ConnectionManager.logger.error(`(${connection.name}:${connection.endpoint}) subscription error`, error)
@@ -177,7 +191,7 @@ export class OperatoConnector implements Connector {
177
191
  subscriptionObserver
178
192
  })
179
193
  ConnectionManager.logger.info(`(${tag}:${scenarioName}) subscription closed flag: ${subscriptionObserver.closed}`)
180
- })
194
+ }
181
195
 
182
196
  client['subscriptions'] = subscriptions
183
197
  ConnectionManager.addConnectionInstance(connection, client)