You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// test.tsimport{describe,test,expect}from'@jest/globals';import{traceSync,traceAsync}from'./baml_client/tracing';functionfnWithReturn() : string{console.log("fnWithReturn");return"Hello, world";}functionfnWithNoReturn() : void{console.log("fnWithNoReturn");}asyncfunctionasyncfnWithReturn() : Promise<string>{console.log("asyncfnWithReturn");returnPromise.resolve("Hello, world");}asyncfunctionasyncfnWithNoReturn() : Promise<void>{console.log("asyncfnWithNoReturn");}describe('Trace Test',()=>{test('traceSync with Return',async()=>{consttracedFnWithReturn=traceSync("tracedFnWithReturn",fnWithReturn);constresult=tracedFnWithReturn();expect(result).toBeDefined();expect(result).toBe('Hello, world');});test('traceSync with no return',async()=>{consttracedFnWithNoReturn=traceSync("tracedFnWithNoReturn",fnWithNoReturn);tracedFnWithNoReturn();});test('traceAsync with Return',async()=>{consttracedFnWithReturn=traceAsync("tracedAsyncFnWithReturn",asyncfnWithReturn);constresult=awaittracedFnWithReturn();expect(result).toBeDefined();expect(result).toBe('Hello, world');});test('traceAsync with no return',async()=>{consttracedFnWithNoReturn=traceAsync("tracedAsyncFnWithNoReturn",asyncfnWithNoReturn);awaittracedFnWithNoReturn();});});
Two tests fail while two other tests appear to pass but print out error messages.
The text was updated successfully, but these errors were encountered:
Fixes#1274
<!-- ELLIPSIS_HIDDEN -->
----
> [!IMPORTANT]
> Fix TypeScript tracing bugs in `BamlCtxManager` by handling undefined
responses and ensuring proper return values.
>
> - **Behavior**:
> - Fix `span.finish` in `BamlCtxManager` to handle undefined `response`
by defaulting to an empty object.
> - Ensure `ctx.run` returns the result in `traceFnSync` and
`traceFnAsync` methods of `BamlCtxManager`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for 8faf23e. It will automatically
update as commits are pushed.</sup>
<!-- ELLIPSIS_HIDDEN -->
---------
Co-authored-by: aaronvg <[email protected]>
Using the traceSync and traceAsync functions in JS cause errors:
I used the following test file in a fresh node install
npm init -y npm install typescript @boundaryml/baml jest ts-jest npx ts-jest config:init npx baml-cli init && npx baml-cli generate npx jest test.ts
Two tests fail while two other tests appear to pass but print out error messages.
The text was updated successfully, but these errors were encountered: