Created
December 27, 2019 10:23
-
-
Save tvvignesh/0e095d0005b17faa3e8c2b3442d9fb24 to your computer and use it in GitHub Desktop.
Just a conversation archive about a bug in Zeebe slack channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vignesh T.V. Nov 14th at 8:05 PM | |
Faced an issue with generating TS constants from BPMN file. Details added here: https://github.com/creditsenseau/zeebe-client-node-js/issues/106 | |
tvvigneshtvvignesh | |
#106 Cannot read property 'zeebe:taskDefinition' of undefined | |
Hi. When trying to generate the Typescript definitions from the bpmn file by doing this: | |
let definitions = await BpmnParser.generateConstantsForBpmnFiles(workflowFile); | |
I get the following error: | |
Cannot read property 'zeebe:taskDefinition' of undefined | |
The path to the bpmn file is correct - not sure how to fix this. Screenshot attached. | |
Screenshot from 2019-11-14 19-59-40 | |
This is the bpmn I am using for testing: | |
``` | |
Show more | |
<https://github.com/creditsenseau/zeebe-client-node-js|creditsenseau/zeebe-client-node-js>creditsenseau/zeebe-client-node-js | Nov 14th | Added by GitHub | |
(87 kB) | |
https://user-images.githubusercontent.com/1165845/68865862-84188e00-0719-11ea-8f77-9f89c96f4e40.png | |
:+1: | |
1 | |
Josh Wulf:house_with_garden: 1 month ago | |
Just checking - this deploys OK to the broker? | |
Vignesh T.V. 1 month ago | |
Yup. The workflow works with the client as well. (edited) | |
Josh Wulf:house_with_garden: 1 month ago | |
Updated the issue. | |
Vignesh T.V. 1 month ago | |
@Josh Wulf I removed the line and I still have the issue. I guess, the time is not good for me today :sob: (edited) | |
Josh Wulf:house_with_garden: 1 month ago | |
That’s strange | |
Josh Wulf:house_with_garden: 1 month ago | |
Can you check this: | |
Josh Wulf:house_with_garden: 1 month ago | |
https://github.com/jwulf/zeebe-client-node-js/commit/8cef4149940cdd32736e17b86ee18ecc8b5e5eec | |
Josh Wulf:house_with_garden: 1 month ago | |
I literally used your bpmn for the unit test | |
Vignesh T.V. 1 month ago | |
@Josh Wulf Oh. Will go through it again and get back to you today | |
Josh Wulf:house_with_garden: 1 month ago | |
K | |
Josh Wulf:house_with_garden: 1 month ago | |
I can’t reproduce that exact error. I got an error about calling split on undefined | |
Vignesh T.V. 1 month ago | |
@Josh Wulf Sorry for the late reply. I just tested it again using the latest version of zeebe-node and zeebe-node-next published to npm (0.22.0-alpha.1) and both doesn't work and I get the same error (after removing the line from the BPMN file which you asked me to do here: https://github.com/creditsenseau/zeebe-client-node-js/issues/106#issuecomment-553944744 | |
jwulfjwulf | |
Comment on #106 Cannot read property 'zeebe:taskDefinition' of undefined | |
This line (#68) is breaking it: | |
<bpmn:message id="Message_0dwun4b" /> | |
Remove that. | |
I'll fix it in the lib so this doesn't break it in the next release. | |
<https://github.com/creditsenseau/zeebe-client-node-js|creditsenseau/zeebe-client-node-js>creditsenseau/zeebe-client-node-js | Nov 14th | Added by GitHub | |
Vignesh T.V. 1 month ago | |
Screenshot of the error | |
Screenshot from 2019-11-17 06-28-18.png | |
Screenshot from 2019-11-17 06-28-18.png | |
Josh Wulf:house_with_garden: 1 month ago | |
Since I can’t reproduce this, my hypothesis is that it is somewhere else in your code. Can you verify that you are actually loading the correct file? | |
Vignesh T.V. 1 month ago | |
@Josh Wulf Sure. One question I had though - are you sure you published the changes to npm? | |
Josh Wulf:house_with_garden: 1 month ago | |
Check the installed code in node_modules. You can insert console.log in there to figure out what’s going on | |
Vignesh T.V. 1 month ago | |
@Josh Wulf I just verified that I am loading the correct file. I emptied the bpmn file and I got the typedef: | |
// Autogenerated constants for arithmetic-operations.bpmn | |
export enum TaskType { | |
} | |
export enum MessageName { | |
} | |
Vignesh T.V. 1 month ago | |
Just logged within the library and saw that tasks array is returning an empty string in the last element of the array. Log below. Same bpmn file used (logged in BpmnParser #237) | |
taskTypes:::: [] | |
tasks:::: [ | |
{ | |
attr: { '@_id': 'ServiceTask_1a3w79q', '@_name': 'Sum1' }, | |
'bpmn:extensionElements': { 'zeebe:taskDefinition': [Object] }, | |
'bpmn:incoming': 'SequenceFlow_12olk0x', | |
'bpmn:outgoing': 'SequenceFlow_1iv5c6g' | |
}, | |
{ | |
attr: { '@_id': 'ServiceTask_1yzmyv2', '@_name': 'Product1' }, | |
'bpmn:extensionElements': { 'zeebe:taskDefinition': [Object] }, | |
'bpmn:incoming': 'SequenceFlow_18aymwi', | |
'bpmn:outgoing': 'SequenceFlow_0v8ecel' | |
}, | |
{ | |
attr: { '@_id': 'ServiceTask_19w53zs', '@_name': 'Final Sum' }, | |
'bpmn:extensionElements': { 'zeebe:taskDefinition': [Object] }, | |
'bpmn:incoming': 'SequenceFlow_0baze6z', | |
'bpmn:outgoing': 'SequenceFlow_06f6bzc' | |
}, | |
'' | |
] | |
t['bpmn:extensionElements']::::: { | |
'zeebe:taskDefinition': { attr: { '@_type': 'sum1', '@_retries': '5' } } | |
} | |
t['bpmn:extensionElements']::::: { | |
'zeebe:taskDefinition': { attr: { '@_type': 'product1', '@_retries': '5' } } | |
} | |
t['bpmn:extensionElements']::::: { | |
'zeebe:taskDefinition': { attr: { '@_type': 'finalsum', '@_retries': '5' } } | |
} | |
t['bpmn:extensionElements']::::: undefined | |
Vignesh T.V. 1 month ago | |
@Josh Wulf The problem is in parsing the BPMN file itself. If I log parsed[0]['bpmn:definitions']['bpmn:process']['bpmn:serviceTask'] in generateConstantsForBpmnFiles function, it gives me: | |
[ | |
{ | |
attr: { '@_id': 'ServiceTask_1a3w79q', '@_name': 'Sum1' }, | |
'bpmn:extensionElements': { 'zeebe:taskDefinition': [Object] }, | |
'bpmn:incoming': 'SequenceFlow_12olk0x', | |
'bpmn:outgoing': 'SequenceFlow_1iv5c6g' | |
}, | |
{ | |
attr: { '@_id': 'ServiceTask_1yzmyv2', '@_name': 'Product1' }, | |
'bpmn:extensionElements': { 'zeebe:taskDefinition': [Object] }, | |
'bpmn:incoming': 'SequenceFlow_18aymwi', | |
'bpmn:outgoing': 'SequenceFlow_0v8ecel' | |
}, | |
{ | |
attr: { '@_id': 'ServiceTask_19w53zs', '@_name': 'Final Sum' }, | |
'bpmn:extensionElements': { 'zeebe:taskDefinition': [Object] }, | |
'bpmn:incoming': 'SequenceFlow_0baze6z', | |
'bpmn:outgoing': 'SequenceFlow_06f6bzc' | |
}, | |
'' | |
] | |
Vignesh T.V. 1 month ago | |
Where the last element is an empty string | |
Josh Wulf:house_with_garden: 1 month ago | |
Hmmmm.... is there something in the bpmn that paraes out like that, or is it an error in the parser? (edited) | |
Josh Wulf:house_with_garden: 1 month ago | |
I upgraded the TS to 3.7 | |
Vignesh T.V. 1 month ago | |
The xmlData is read properly but when this line comes: var parsedresp = parser.parse(xmlData, BpmnParser.parserOptions); that is when the extra string comes to the array | |
Josh Wulf:house_with_garden: 1 month ago | |
So I could optionally chain that expression in the code, which would stop it throwing; but That I can’t reproduce it is a problem (edited) | |
Vignesh T.V. 1 month ago | |
one sec. can i share xmlData with u | |
Vignesh T.V. 1 month ago | |
Here you go. This is what the parser gives me back in xmlData when it reads the file. | |
https://gist.github.com/tvvignesh/0dad246e17b068684c6630547a6926b3 | |
Vignesh T.V. 1 month ago | |
Maybe, you can try hardcoding it to xmlData variable and you might get the issue | |
Josh Wulf:house_with_garden: 1 month ago | |
Can you make a minimal reproducer repo? | |
Josh Wulf:house_with_garden: 1 month ago | |
Something like this: https://github.com/jwulf/zeebe-reproducer-1 | |
jwulf/zeebe-reproducer-1 | |
A minimal reproducer for a Zeebe SNAPSHOT issue | |
Language | |
TypeScript | |
Last updated | |
10 months ago | |
<https://github.com/jwulf/zeebe-reproducer-1|jwulf/zeebe-reproducer-1>jwulf/zeebe-reproducer-1 | Jan 25th | Added by GitHub | |
Josh Wulf:house_with_garden: 1 month ago | |
Doesn’t have to be as elaborate, but if you can get a reproducer in front of me, I can fix it | |
Vignesh T.V. 1 month ago | |
Yup. Actually I am struggling to create a reproducer project myself :rolling_on_the_floor_laughing: because the error occurs only within my project but if I create a new one, I am struggling to reproduce the error | |
Vignesh T.V. 1 month ago | |
It works perfect in a new project. Will share details in 15 min | |
:+1: | |
1 | |
Vignesh T.V. 1 month ago | |
@Josh Wulf Now, this is getting way way crazier. I had this file for GraphQL server and this is causing the issue I reported. Not at all sure how this is affecting Zeebe. | |
/** | |
* WRAPPER ABOVE PHOTON | |
*/ | |
import { Photon } from '../db/prisma/node_modules/@generated/photon'; | |
import { DataSource } from 'apollo-datasource'; | |
class Store extends DataSource { | |
store: Object; | |
context: Object; | |
constructor() { | |
super(); | |
this.store = new Photon(); | |
} | |
initialize(config) { | |
this.context = config.context; | |
} | |
getStore() { | |
return new Photon(); | |
} | |
} | |
export { Store }; | |
Vignesh T.V. 1 month ago | |
If I comment this out, everything works :rolling_on_the_floor_laughing: | |
Josh Wulf:house_with_garden: 1 month ago | |
what about the thing that imports that? | |
Vignesh T.V. 1 month ago | |
Its just import { Store } from './db.utils'; not sure what is wrong here. If I remove everything and just do console.log(Store) in the file where I am importing this, i get the error. | |
Vignesh T.V. 1 month ago | |
Will there be some issue when typescript is transpiled? | |
Josh Wulf:house_with_garden: 1 month ago | |
It could be prototype pollution | |
Vignesh T.V. 1 month ago | |
Ahh.. I got it, when I remove the photon import, it works. If I change the code to this, it works: | |
Vignesh T.V. 1 month ago | |
/** | |
* WRAPPER ABOVE PHOTON | |
*/ | |
// import { Photon } from '../db/prisma/node_modules/@generated/photon'; | |
import { DataSource } from 'apollo-datasource'; | |
class Store extends DataSource { | |
store: Object; | |
context: Object; | |
constructor() { | |
super(); | |
this.store = {}; | |
// this.store = new Photon(); | |
} | |
initialize(config) { | |
this.context = config.context; | |
} | |
getStore() { | |
return {}; | |
// return new Photon(); | |
} | |
} | |
export { Store }; | |
Vignesh T.V. 1 month ago | |
So, photon is the culprit | |
Josh Wulf:house_with_garden: 1 month ago | |
either its code, or a side-effect of importing it like that | |
Vignesh T.V. 1 month ago | |
Hmm.. Actually the file I am importing (photon) generated by the Prisma2 Photon CLI - https://photonjs.prisma.io/ | |
PrismaPrisma | |
Photon - Type-safe database access (ORM) | |
Photon is an auto-generated database client (ORM*) for JavaScript/TypeScript based on your DB schema.(43 kB) | |
https://photonjs.prisma.io//photon-og-image.png | |
Vignesh T.V. 1 month ago | |
Not hand-written. | |
Josh Wulf:house_with_garden: 1 month ago | |
i’d try moving the file into your src root and see if it still has the issue | |
Josh Wulf:house_with_garden: 1 month ago | |
if it has imports in it, it may be those | |
Josh Wulf:house_with_garden: 1 month ago | |
the Zeebe parser may be getting a dep from the module cache populated by that | |
Vignesh T.V. 1 month ago | |
@Josh Wulf Hmm. Possible. Let me raise an issue in Photon forum tonight. Will see what they have to say | |
Josh Wulf:house_with_garden: 1 month ago | |
Well, we found and fixed one bug in the node client with this | |
:+1: | |
1 | |
Vignesh T.V. 1 month ago | |
@Josh Wulf I have created a repository for this issue here: https://github.com/tvvignesh/prisma-zeebe-bug | |
You can test it out and you will find the bug. | |
tvvignesh/prisma-zeebe-bug | |
This repository shows the issues faced when running Prisma and Zeebe together | |
Language | |
JavaScript | |
Last updated | |
a few seconds ago | |
<https://github.com/tvvignesh/prisma-zeebe-bug|tvvignesh/prisma-zeebe-bug>tvvignesh/prisma-zeebe-bug | Nov 17th | Added by GitHub | |
Vignesh T.V. 1 month ago | |
@Josh Wulf Saw your issue. Did you clone the node_modules as well? The @generated folder is within that | |
Vignesh T.V. 1 month ago | |
Oh. I am able to reproduce it. When you do npm install, it is removing the @generated folder. Hence the issue. We will have to take a backup of it and put it back again | |
Josh Wulf:house_with_garden: 1 month ago | |
As a workaround, generate your BPMN constants in a different file from the photon stuff. It’s usually used in an npm task |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment