Skip to content
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

v0.3.0-beta crashes with Invalid protocol results #66

Closed
printfn opened this issue Mar 11, 2025 · 4 comments
Closed

v0.3.0-beta crashes with Invalid protocol results #66

printfn opened this issue Mar 11, 2025 · 4 comments

Comments

@printfn
Copy link

printfn commented Mar 11, 2025

import 'temporal-polyfill/global';

const zdt1 = Temporal.PlainDate.from('2025-01-09').toZonedDateTime('UTC');
const zdt2 = zdt1.add({ hours: 12 });
console.log(zdt1.toString());
const duration = Temporal.ZonedDateTime.from('2025-03-11T18:00Z[UTC]').until(zdt2, { largestUnit: 'days', smallestUnit: 'seconds' });
console.log(duration.toString());

This prints zdt1 as 2025-01-09Tundefined:undefined:undefined.000000NaN+00:00[UTC] and then the until call crashes with:

file:///path/node_modules/temporal-polyfill/chunks/internal.js:1944
      throw new RangeError(co);
            ^

RangeError: Invalid protocol results
    at file:///path/node_modules/temporal-polyfill/chunks/internal.js:1944:13
    at diffZonedEpochsBig (file:///path/node_modules/temporal-polyfill/chunks/internal.js:1948:5)
    at pe (file:///path/node_modules/temporal-polyfill/chunks/internal.js:1860:11)
    at Temporal.ZonedDateTime.until (file:///path/node_modules/temporal-polyfill/chunks/classApi.js:509:29)
    at Temporal.ZonedDateTime.until (file:///path/node_modules/temporal-polyfill/chunks/classApi.js:10:16)
    at file:///path/index.ts:6:72
    at ModuleJob.run (node:internal/modules/esm/module_job:273:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:600:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5)

On v0.2.5 it outputs:

2025-01-09T00:00:00+00:00[UTC]
-P61DT6H
@arshaw
Copy link
Member

arshaw commented Mar 11, 2025

Thank you @printfn, confirmed:
https://stackblitz.com/edit/vitejs-vite-hceucw5w?file=src%2Fmain.js&terminal=dev

This doesn't happen when the CDN build is used, so it must be an issues related to how I'm compiling for ESM.

I will look into it very soon and release a beta patch

@printfn
Copy link
Author

printfn commented Mar 11, 2025

I'm not sure but I think the CDN build has the issue too?

https://stackblitz.com/edit/vitejs-vite-23qtndmf?file=index.html

@arshaw
Copy link
Member

arshaw commented Mar 12, 2025

This is fixed in v0.3.0-beta.1. Had some issues with minification mangling property names incorrectly, and there was a bug where the CI didn't run tests against the minified version.

@arshaw arshaw closed this as completed Mar 12, 2025
@printfn
Copy link
Author

printfn commented Mar 12, 2025

Thanks! I tested with the new release and it seems to be working well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants