Skip to content

Commit

Permalink
fix: replace APP_VERSION with webpack global __APP_VERSION__ (#10824)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Krick <[email protected]>
  • Loading branch information
mattkrick authored Feb 6, 2025
1 parent d25c11c commit e478b10
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/embedder/embedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tracer.init({
service: `embedder`,
appsec: process.env.DD_APPSEC_ENABLED === 'true',
plugins: false,
version: process.env.npm_package_version
version: __APP_VERSION__
})
// The embedder queue is in PG & gets hits non-stop, which dirties up the logs. Ignore the polling query before enabling pg
// tracer.use('pg')
Expand Down
2 changes: 1 addition & 1 deletion packages/embedder/establishPrimaryEmbedder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const establishPrimaryEmbedder = async (redis: RedisInstance) => {
const MAX_TIME_BETWEEN_WORKER_STARTUPS = ms('5s')
try {
const primaryWorkerLock = await redlock.acquire(
[`embedder_isPrimary_${process.env.npm_package_version}`],
[`embedder_isPrimary_${__APP_VERSION__}`],
MAX_TIME_BETWEEN_WORKER_STARTUPS
)
return primaryWorkerLock
Expand Down
2 changes: 1 addition & 1 deletion packages/gql-executor/gqlExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tracer.init({
service: `gql`,
appsec: process.env.DD_APPSEC_ENABLED === 'true',
plugins: false,
version: process.env.npm_package_version
version: __APP_VERSION__
})
tracer.use('ioredis').use('http').use('pg')

Expand Down
3 changes: 1 addition & 2 deletions packages/server/initSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ declare global {
}
}

const APP_VERSION = process.env.npm_package_version
Sentry.init({
environment: 'server',
dsn: process.env.SENTRY_DSN,
release: APP_VERSION,
release: __APP_VERSION__,
ignoreErrors: [
'429 Too Many Requests',
/language \S+ is not supported/,
Expand Down
2 changes: 1 addition & 1 deletion packages/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tracer.init({
service: `web`,
appsec: process.env.DD_APPSEC_ENABLED === 'true',
plugins: false,
version: process.env.npm_package_version
version: __APP_VERSION__
})
tracer.use('ioredis').use('http').use('pg')

Expand Down
3 changes: 1 addition & 2 deletions packages/server/socketHandlers/handleOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import checkBlacklistJWT from '../utils/checkBlacklistJWT'
import sendToSentry from '../utils/sendToSentry'
import handleConnect from './handleConnect'

const APP_VERSION = process.env.npm_package_version
export type SocketUserData = {
connectionContext: ConnectionContext
authToken: AuthToken
Expand Down Expand Up @@ -51,7 +50,7 @@ const handleOpen: WebSocketBehavior<SocketUserData>['open'] = async (socket) =>

// messages will start coming in before handleConnect completes & sit in the readyQueue
const nextAuthToken = await handleConnect(connectionContext)
sendEncodedMessage(connectionContext, {version: APP_VERSION, authToken: nextAuthToken})
sendEncodedMessage(connectionContext, {version: __APP_VERSION__, authToken: nextAuthToken})
keepAlive(connectionContext)
}

Expand Down
4 changes: 1 addition & 3 deletions packages/server/sse/SSEConnectionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import getQueryToken from '../utils/getQueryToken'
import uwsGetIP from '../utils/uwsGetIP'
import sendSSEMessage from './sendSSEMessage'

const APP_VERSION = process.env.npm_package_version

const SSEConnectionHandler = uWSAsyncHandler(async (res: HttpResponse, req: HttpRequest) => {
const authToken = getQueryToken(req)
const connectionContext = new ConnectionContext(res, authToken, uwsGetIP(res, req))
Expand Down Expand Up @@ -46,7 +44,7 @@ const SSEConnectionHandler = uWSAsyncHandler(async (res: HttpResponse, req: Http
if (res.done) return
res.tryEnd(`retry: 1000\n`, 1e8)
sendSSEMessage(res, connectionContext.id, 'id')
sendEncodedMessage(connectionContext, {version: APP_VERSION, authToken: nextAuthToken})
sendEncodedMessage(connectionContext, {version: __APP_VERSION__, authToken: nextAuthToken})
keepAlive(connectionContext)
}, true)

Expand Down

0 comments on commit e478b10

Please sign in to comment.