-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
thrift-server: (extra-large) update dependencies, rename @creditkarma -> @statestitle #5
Conversation
}, | ||
"devDependencies": { | ||
"lerna": "^3.14.1" | ||
"lerna": "^4.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing no breaking changes we care about
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the changelog: https://github.com/lerna/lerna/blob/main/CHANGELOG.md
It didn't seem like anything that I was too worried about, a lot of exports but I don't think this code uses lerna
programmatically, and the only other thing was dropping Node 6 and 8 support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests passed for me!
there are some creditkarma things in README but they don't really matter:
$ git grep credit.*thrift-client
README.md:} from '@creditkaram/thrift-client'
README.md:} from '@creditkaram/thrift-client'
packages/thrift-client-zipkin-filter/README.md:} from '@creditkaram/thrift-client'
🎉
ooh, thanks - I'll fix those, I think at first I was skipping the README files and then I went back to update them too, but obviously missed some. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whew, thanks for making all these changes.
@@ -177,10 +177,14 @@ export class Connection { | |||
} | |||
} | |||
} catch (err) { | |||
let message = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there's a better pattern we should use here. Like use "Unknown" if it's not an instanceof Error? Or err = message
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll make the default message be Unknown
, seems like a decent idea.
code: { status: new thrift.Int64(0) }, | ||
value: 'test', | ||
}, | ||
{ skip: ['_annotations', '_fieldAnnotations'] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to skip comparing these fields now? (in this file and in others in the PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were some changes in the @hapi/code
library (test matchers, https://github.com/hapijs/code) that seem to make this not work the way it was before - specifically object comparisons where one is missing keys that the other has. I think that it may have been caused by this change?
Anyways, the tests were failing because those two keys were present in the resulting object but not in the object here in the test. I couldn't figure out a better way to do this other than skipping the problematic properties (the includes
function didn't seem to do it). In Jest I'd just use expect.objectContaining
but I couldn't find similar functionality in @hapi/code
.
@@ -47,7 +47,7 @@ function is128bit(traceId: TraceId): boolean { | |||
export function serializeLinkerdHeader(traceId: TraceId): string { | |||
const serialized: ByteBuffer = ByteBuffer.concat([ | |||
ByteBuffer.fromHex(traceId.spanId), | |||
ByteBuffer.fromHex(traceId.parentId), | |||
ByteBuffer.fromHex(traceId.parentSpanId.getOrElse('')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I don't understand the getOrElse() API. It seems like it makes things hard to use. Can parentSpanId ever actually be unset? Is it really safe to use an empty string in those cases?
I'm obviously not familiar with any of the code in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the zipkin
library updates (used for request tracing, it seems) changed the name but also wrapped these fields in some kind of Optional
object where you have to call this method or something similar to unwrap the actual value (it's similar to other Java APIs I've seen in the past for wrapping possible null
values). You can call getOrElse()
without a default value and it would be string | undefined
, but the fromHex
function requires a string
, so this seemed like the closest equivalent to how it would have been before? All the tests pass and this seems like the best equivalent - apparently parentSpanId
can be unset (otherwise it wouldn't be this Optional
type), and I believe an empty string is pretty safe to use (certainly more so than a null
or undefined
value).
I'm not crazy about the syntax either (obviously a ??
would seem a bit nicer than calling getOrElse
) but I also don't know how to really get that changed other than switching it to a different library. 🤷
Thanks for reviewing them! |
All the dependency versions have been updated to their latest, some notable things:
typescript
- set to~4.4.4
since the 4.5.x line has some performance issues and breaks thrift code generation due to some changed APIsnew Promise(...)
needing to be changed tonew Promise<void>(...)
in a few places, as well as needing to doinstanceof
checks on caught errors since they're now typed asunknown
by default@types/node
- set to^12.20.41
to support Node 12 and up, since they're the current LTS versionsBuffer
APIs that no longer allowed a boolean parameter for turning assertions on/offtslint
- set to the highest version available, but the entiretslint
package is deprecated in favor ofeslint
and@typescript-eslint
. This PR is big enough as it is without trying to also fix that.prettier
upgrade, there were a bunch of linting fixes in this PRzipkin
- this upgrade involved renamingparentId
toparentSpanId
, but also unwrapping some of the optional values usinggetOrElse
Also, all the
@creditkarma
instances have been renamed to@statestitle
for consistency, and Github links were fixed to point at the StatesTitle repo.@statestitle/typescript-thrift
library, which means that exceptions can't use themessage
field without it being required. Also, some tests were expecting to get a specificmessage
string, so the thrift files were updated to add the exception to thethrows
clause and set the message correctly in the server code.All tests pass now, but to try this out you'll need to run
npm run clean
,npm install
, thennpm test
.