TC39 stage 3 decorators not working anymore in Deno Deploy

As of Feb 15th, deployments to #deploy™ fail when using TC39 decorators. Despite the decision to support legacy decorators in Deno 1.40+, see @bartlomieju 's post here https://github.com/denoland/deno/issues/19160#issuecomment-1855462766, when compiling, the experimentalDecorators config is ignored and I suspect any decorator, including the TS 5.0 ones, causes compilation to fail. I'm supposed to go live in a few weeks and I my app doesn't run on Deno Deploy anymore. https://github.com/denoland/deno/issues/19160#issuecomment-1949548670 https://github.com/denoland/deno/issues/22419
GitHub
TC39 stage 3 decorators do not work with bundle or compile · Issue ...
$ deno --version deno 1.40.4 (release, x86_64-pc-windows-msvc) v8 12.1.285.6 typescript 5.3.3 The TC39 stage 3 decorators sample provided by https://deno.com/blog/v1.40#decorators does not work wit...
GitHub
Typescript 5 decorators · Issue #19160 · denoland/deno
Release 1.32.0 comes with Typescript 5.0.2. But, as per notes in this PR I see no modern (stage 3) decorators support. As far as I understand, the problem is about SWC. But SWC supports them in the...
DAH
Deno AI Helper65d ago
I apologize, but I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided in your message, it seems like there might be an issue with the Deno Deploy compilation process regarding decorators. While I cannot provide a solution based on the Deno documentation, I can suggest ensuring that your TypeScript configuration is set up correctly to enable experimental support for decorators if you haven't done so already. This typically involves setting the experimentalDecorators option to true in your tsconfig.json file. Please note that this advice is not based on the Deno documentation, and I advise you to double-check the accuracy of this advice. Since this is a recent issue, it might also be helpful to keep an eye on the GitHub issues you've linked to see if there are any updates or workarounds provided by the Deno team or community. If the problem persists, consider reaching out on the GitHub issues for further assistance from the Deno developers.
C
CodeSnaporaz65d ago
experimentalDecorators option is correctly set as per my comments in the github issue. This looks like a breaking change introduced by the adoption of the newest deno runtime in #deploy™ . It's likely affecting all the applications that use decorators. Any new deployment is likely to break for this applications. Seems quite serious from my perspective.
DAH
Deno AI Helper65d ago
I understand the severity of the situation, especially with your upcoming live deployment. It does seem like a critical issue if the adoption of the newest Deno runtime in Deno Deploy is causing breaking changes for applications that use decorators. Given that you have already set the experimentalDecorators option correctly and have provided information on GitHub, the best course of action would be to actively engage with the Deno team through the GitHub issues you've mentioned. Since this is a recent and potentially widespread issue, the Deno team is likely to prioritize a fix or provide a workaround. In the meantime, here are a few steps you can take: 1. Monitor the GitHub Issues: Keep an eye on the existing GitHub issues for any updates or comments from the Deno team. They might provide a temporary workaround or a patch. 2. Engage with the Community: Continue to engage with the community on the Deno Discord and GitHub. Other developers might be experiencing the same issue and could have insights or workarounds. 3. Prepare for a Rollback: If possible, prepare to rollback to a previous version of your application that is stable on Deno Deploy, until the issue is resolved. 4. Local Testing: If you haven't already, try to replicate the issue locally with the same Deno runtime version used in Deno Deploy to see if you can identify any additional information that could help resolve the issue. 5. Alternative Deployment Strategies: As a last resort, consider if there are alternative deployment strategies that could be used temporarily, such as containerization, until the issue is resolved. Remember to keep all communication with the Deno team constructive and provide as much detail as possible to help them understand and address the issue
B
bartlomieju64d ago
Ack, i will look into the problem once I'm back at work @CodeSnaporaz when was the last time you tried deploying it?
C
CodeSnaporaz64d ago
No description
C
CodeSnaporaz64d ago
"minor changes" as in "gaaack! wth is going on?" 😄 Just to give you some further background: I DIFFed the two commits at the bottom to see what was different. The only change was an (unused) import in deno.jsonc:
{
"imports": {
"ics" : "npm:ics"
//...
}
{
"imports": {
"ics" : "npm:ics"
//...
}
I reverted that change but it made no difference.
C
CodeSnaporaz64d ago
Compiles and runs in 1.39.4, breaks in 1.40.0
No description
B
bartlomieju64d ago
Can you try deploying again today?
C
CodeSnaporaz64d ago
I can now if that works for you.
C
CodeSnaporaz64d ago
No description
B
bartlomieju63d ago
Thanks. I'll be back in work on Wednesday so I'll take care of it
C
CodeSnaporaz63d ago
Much appreciated
B
bartlomieju61d ago
We've identified a fix and are working on deploying it The fix has been deployed now
C
CodeSnaporaz61d ago
That's impressive. Go Deno team. What was the fix? Do we have it tracked on GitHub? Locally still fails so I suspect it's a hot-fix on #deploy™ for the time being, right?
B
bartlomieju61d ago
Deploy misssed reading configuration when it was updated to the latest Deno runtime What does file locally? Can you show me the repro? It should work correctly in any 1.40.x release
C
CodeSnaporaz61d ago
same repo that now succeeds on Deploy. It's a private one. The failure happens when executing a compiled deno app as per https://discord.com/channels/684898665143206084/1208544667038388295/1208894962830282793 I tried this morning with runtime 1.40.5. Is there any argument to be passed to deno compile or the executable in order for the decorators to be recognized?
B
bartlomieju61d ago
-.- Okay, so it's in deno compile
C
CodeSnaporaz61d ago
I'd imagine so. But how come #deploy™ is now working?
B
bartlomieju61d ago
Because we updated Deploy to respect the configuration
C
CodeSnaporaz61d ago
does deploy use different tools from deno compile?
B
bartlomieju61d ago
It uses the same tools, but there are various knobs that can be tweaked Looks like we missed to turn the knob in deno compile. I'm looking into the problem right now. Can reproduce it
B
bartlomieju61d ago
GitHub
fix(compile): respect compiler options for emit by bartlomieju · Pu...
deno compile was ignoring configuration file and thus not applying compilerOptions to influence the way files were emitted.
C
CodeSnaporaz61d ago
Marvellous! In the meantime I truly appreciate the fix in Deploy.
B
bartlomieju61d ago
Sure thing, sorry for the problems
C
CodeSnaporaz61d ago
Tested 1.41.0. Working now. Thanks a lot
F
fro.profesional58d ago
@bartlomieju I'm currently trying to deploy this:
import "npm:reflect-metadata";
import { injectable, container } from "npm:tsyringe";

class Module {
constructor() { }

some() {
return "some"
}
}

@injectable()
class App {

constructor(
private module: Module
) { }

callSome() {
return this.module.some()
}
}

const app = container.resolve(App);

Deno.serve(() => {
return new Response(app.callSome())
})
import "npm:reflect-metadata";
import { injectable, container } from "npm:tsyringe";

class Module {
constructor() { }

some() {
return "some"
}
}

@injectable()
class App {

constructor(
private module: Module
) { }

callSome() {
return this.module.some()
}
}

const app = container.resolve(App);

Deno.serve(() => {
return new Response(app.callSome())
})
It works, locally but it fails to deploy with the following error:
error: The deployment failed: UNCAUGHT_EXCEPTION

Error: TypeInfo not known for "App"
at file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:292:27
at InternalDependencyContainer.construct (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:297:11)
at InternalDependencyContainer.resolve (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:114:33)
at file:///src/main.ts:25:23
error: The deployment failed: UNCAUGHT_EXCEPTION

Error: TypeInfo not known for "App"
at file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:292:27
at InternalDependencyContainer.construct (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:297:11)
at InternalDependencyContainer.resolve (file:///node_modules/.deno/tsyringe@4.8.0/node_modules/tsyringe/dist/cjs/dependency-container.js:114:33)
at file:///src/main.ts:25:23
Is that expected? I'm deploying a main.ts file and a deno.json with emitDecoratorMetadata and experimentalDecorators both set to true
B
bartlomieju58d ago
Does it work with Deno V1.40.4?
F
fro.profesional57d ago
Sorry for the late response It works with - deno 1.41.0 in local - deno 1.40.4 in local FYI: the errors I see while trying to deploy are the same as if no compilerOptions where used on local, so maybe the configuration from deno.json is not being applied?
No description
C
CodeSnaporaz57d ago
It look like a separate issue from the decorators one. The exception is complaining about the type of App , unless I'm mising something.
F
fro.profesional57d ago
It complains that the TypeInfo not known for "App" since the decorators are not working, when they work (in local for example) there is no error This decorators help to inject at runtime a instance of the given class when resolvig from the container
C
CodeSnaporaz57d ago
What I'm trying to say is that, if the runtime gets to dependency-container.js in relation to App, it seems to mean that the decorators are recognised as such. It looks like a red herring to me. Surely, if there's something that won't work in Deploy, that suggests that there are differences in the way the app is running. Have you tried running the app as a compiled bundle or are you only running it straight with deno run?
F
fro.profesional57d ago
I'm only running it straight with deno run
C
CodeSnaporaz57d ago
ok, I'd suggest you try to compile it and run the executable. If you get the same issue locally, you might be able to isolate the problem more easily.
C
CodeSnaporaz57d ago
As a side note, are you at the beginning of your project? I see that tsyringe is an node package. I'm successfully using Oak-decorators, which I updated myself, successfully. At the moment I'm importing it from a github fork as I yet have to find the time to do the pull request. https://github.com/cleverplatypus/oak-decorators
GitHub
GitHub - cleverplatypus/oak-decorators: Project implements decorato...
Project implements decorators for oak like Nest.js. - Replaced reflect_metadata with deno_reflect - cleverplatypus/oak-decorators
C
CodeSnaporaz57d ago
I suspect the project was abandoned because reflect_metadata was a dud that prevented the whole thing from working. Luckily deno introduced the scopes configuration, which allowed me to add the drop-in replacement.
F
fro.profesional57d ago
I’ll try that, thanks 🙏 !
C
CodeSnaporaz57d ago
GitHub
Added support for custom decorators, made it work with deno_reflect...
Hey, I found this good project, it looked like it wasn't very active, possibly because the dependency with reflect_metadata was preventing it from working at all, at least in recent versions of...
C
CodeSnaporaz57d ago
Pleasure. If you need help, feel free to open a topic.
C
CodeSnaporaz57d ago
lastly, a bit of shameless self-promotion, if you feel like using/supporting any of my npm packages... https://www.npmjs.com/package/http-request-factory (Deno compatible) https://www.npmjs.com/package/tiny-object-validator (Deno compatible) https://www.npmjs.com/package/signals.ts (Deno compatible) https://www.npmjs.com/package/vue3-routable (Vue3 -duh - if you use Vue and like decorators)
npm
http-request-factory
!GitHub release   !. Latest version: 0.0.19, last published: 9 days ago. Start using http-request-factory in your project by running `npm i http-reque...
npm
tiny-object-validator
Small library to organise JavaScript/TypeScript objects' validation. Latest version: 1.0.1, last published: a month ago. Start using tiny-object-validator in your project by running npm i tiny-object-validator. There are no other projects in the npm registry using tiny-object-validator.
npm
signals.ts
!Tests. Latest version: 1.0.4, last published: 21 days ago. Start using signals.ts in your project by running npm i signals.ts. There are no other projects in the npm registry using signals.ts.
npm
vue3-routable
Small utility to annotate classes of objects to be activated/deactivated upon vue-router routes change . Latest version: 0.1.8, last published: 6 months ago. Start using vue3-routable in your project by running npm i vue3-routable. There are no other projects in the npm registry using vue3-routable.
S
Sorikairo57d ago
Dropping in because oak decorators is really close to https://github.com/Savory/Danet Last time I checked around 6 months ago, deploy does not handle emitDecoratorsMetadata while the runtime does,so if you rely on paramstype metadata it won’t work. Maybe it has been implemented since @bartlomieju ? If it has not been implemented/fixed yet, @fro.profesional you have to first bundle your app in your ci/locally with the emitDecoratorMetadata options and then upload the bundle to deploy. Here is a guide to do so https://danet.land/deno-deploy.html It is made for Danet app but the concepts apply to any app that uses decorators and thus specific compiler options
C
CodeSnaporaz57d ago
oak-decorators doesn't rely on emitted metadata, as far as I can remember. At any rate it works with Deploy like a charm.
S
Sorikairo56d ago
Yes, but for fro's usecase, which is dependency injection (if I understood correctly the piece of code they gave), it probably needs it. But also just noticed it uses some npm packages, so maybe more shenanigans
C
CodeSnaporaz56d ago
oak-decorator does DI via the @Injectable decorator. I don't use that much in my projects as I'm but it's there.
C
CodeSnaporaz56d ago
Danet is a complete solution (framework as they describe it) I guess oak-decorators is a discrete library that works on top of Oak, so I guess that if someone is familiar with Oak, it's an easy addition. might be in the config, doesn't mean it's relied upon.
S
Sorikairo56d ago
Without it, swc and tsc do not emit constructors and methods paramstype, so DI cannot work AFAIK
C
CodeSnaporaz56d ago
I seem to remember that, when I looked into it, I noticed that it was keeping a custom hash of metadata. I might be wrong. Once it was working, I stopped looking 😄
S
Sorikairo56d ago
But then, if you say that it works on Deploy without any bundling (and I believe you) it either means Deploy handles it now, or they do it another way. In both case, that's awesome
C
CodeSnaporaz56d ago
It always worked once I replaced reflect_metadata with deno_reflect the issue with reflect_metadata I think was some dependency with microsoft stuff or dom, don't remember
S
Sorikairo56d ago
But deno_reflect also need emitDecoratorMetadata as stated by their doc https://deno.land/x/deno_reflect@v0.2.0 (it's also what Danet uses)
C
CodeSnaporaz56d ago
I think they guy who first wrote oak-decorator bumped into the issue and found a workable strategy. I just stood on the shoulder of such giant and added some customisation that served me well.
S
Sorikairo56d ago
Do you have any open source repo of a project you deployed on Deno deploy that uses it by any chance ? it's on the back of my head for 2 years, if it gives me a resolution it would be cool (already starring all the repo you linked, for fairness)
C
CodeSnaporaz56d ago
Not open source ones, I'm afraid. Working on a couple of commercial products at the moment. They both use oak-decorators. One should launch in a few weeks.
S
Sorikairo56d ago
Gotcha, sad, but glad it works on Deploy for you then
F
fro.profesional56d ago
@Sori [He/Him] do you know of an alternative to deno bundle?
S
Sorikairo56d ago
I would say any bundling library such as esbuild ? I believe there were a few very valuable contribution to plugin to handle Deno well
N
NDH56d ago
More Posts
Use Deno permissions in your own CLIIf I create a CLI with Deno, can I somehow reuse or pass on the permissions? ```bash > mycli --alloHas someone worked on a win32/x11/mac native window creation using FFI?Using only operating system native libraries? No SDL, etc.How to unset white background of SVG in Jupyter notebook?I’ve got a Jupyter notebook with Deno kernel in VSCode that displays an SVG. The SVG has a forced whHow to get the Docker ARM image for DenoI keep getting this error when trying to deploy my code: ``` WARNING: The requested image's platfoDeno compiled bin not create fileHi, I have a script that create file with Deno.writeFileSync() on current location When run script VSCode Extension Failing ot Initialize:party_deno: **RESOLVED** :party_deno: Having a bit of trouble using the VSCode Extension. `deno`deno command stdin, stdout continous readingI am trying to spawn an AI (cpp code) however after launching the code it immediately exits. It alsoProblem rerender a island when updating the value of a signal!Hi there im trying to make a visual change to the selected category button. However it does not rereCannot find namespace NodeJSHi Context: using deno with npm lib (imap). There seems to be a missing/unresolved to NodeJS that Which components exactly should be islands?Hi! I am currently developing a web app using fresh and I am getting confused about the usage of islError using npm:ssh2-sftp-client@10.0.3I am trying to connect to a sftp server using the library mentioned in the title (that is a wrapper How to restrict global scope in dynamically created function?I want to dynamically create a function using Function() constructor. How can I restrict access to gTyping for Dynamic importsSo I have a function like this that uses a dynamic import like ```ts export async function func1(imError with fetch called from npm moduleI am trying to use the `tsdav` NPM package with Deno, and have run into a problem with making an HTTCompile to exeEvery time I run my exe I get the following error, But when I start my code normally with node main.What does this library "assert" does?Hi https://deno.land/std@0.215.0/assert/mod.ts What does it do in this example? https://docs.deno.coWhat does this library "assert" does?https://deno.land/std@0.215.0/assert/mod.ts What does it do in this example? https://docs.deno.com/rLooking for an alternative to deno_domHi I'm looking for an alternative library to https://deno.land/x/deno_dom@v0.1.45/deno-dom-wasm.ts PCompile to exeEvery time I run my exe I get the following error: But when I start my code normally with node maiRunning untrusted code, eval-styleI have a project that on occassion I want to be able to execute JS code that I can then quickly get