denoland / deployctl Goto Github PK
View Code? Open in Web Editor NEWCommand line tool for Deno Deploy
Home Page: https://deno.com/deploy
License: MIT License
Command line tool for Deno Deploy
Home Page: https://deno.com/deploy
License: MIT License
Given a module internally calls Deno.test
When deployctl
runs a JSX that imports that module
Then the following error is shown:
error: TS2339 [ERROR]: Property 'test' does not exist on type 'typeof Deno'.
return Deno.test(testName, () => assert(assertion.evaluate()));
Getting the below error.
error: Uncaught (in promise) TypeError: HEAD and GET requests may not have a body.
this.#request = new Request(new URL(stdReq.url, `http://${host}`).toString(), {
^
at new Request (deno:op_crates/fetch/23_request.js:273:15)
at new FetchEvent (https://deno.land/x/[email protected]/src/runtime.bundle.js:2551:25)
at serve1 (https://deno.land/x/[email protected]/src/runtime.bundle.js:2612:30)
error: Process exited with code 1
Reproduction:
addEventListener("fetch", (event) => {
event.respondWith(fetch(new URL("local.js", import.meta.url)));
});
deployctl run local.js
I'm trying to run quotes.ts
from https://deno.com/deploy/docs/tutorial-faunadb but it'll give me error messages below.
I'm not sure how to resolve the conflict error:
→ deployctl run ./quotes.ts
Check file:///Users/marcosvm/code/deno/quotes/$deno$eval.ts
error: TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
interface Account {
~~~~~~~~~
at asset:///lib.dom.d.ts:25:1
Conflicts are in this file.
declare class DOMException extends Error {
~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:11:1
TS2430 [ERROR]: Interface 'ReadableStreamDefaultReader<R>' incorrectly extends interface 'ReadableStreamGenericReader'.
Types of property 'closed' are incompatible.
Type 'Promise<void>' is not assignable to type 'Promise<undefined>'.
Type 'void' is not assignable to type 'undefined'.
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.dom.d.ts:12597:11
TS2345 [ERROR]: Argument of type 'unknown' is not assignable to parameter of type 'VNode<{}>'.
return new Response(render(jsx), {
~~~
at https://deno.land/x/[email protected]/util.ts:22:30
TS2339 [ERROR]: Property 'keys' does not exist on type 'URLSearchParams'.
for (const param of searchParams.keys()) {
~~~~
at https://deno.land/x/[email protected]/util.ts:72:38
TS2339 [ERROR]: Property 'keys' does not exist on type 'Headers'.
for (const header of request.headers.keys()) {
~~~~
at https://deno.land/x/[email protected]/util.ts:95:42
TS2304 [ERROR]: Cannot find name 'body'.
const { quote, author } = body;
~~~~
at file:///Users/marcosvm/code/deno/quotes/quotes.ts:36:31
TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
declare class DOMException extends Error {
~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:11:1
Conflicts are in this file.
interface Account {
~~~~~~~~~
at asset:///lib.dom.d.ts:25:1
TS2403 [ERROR]: Subsequent variable declarations must have the same type. Variable 'ReadableStreamDefaultReader' must be of type '{ new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>; prototype: ReadableStreamDefaultReader<any>; }', but here has type '{ new <R>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>; prototype: ReadableStreamDefaultReader<any>; }'.
declare var ReadableStreamDefaultReader: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:521:13
'ReadableStreamDefaultReader' was also declared here.
declare var ReadableStreamDefaultReader: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.dom.d.ts:12602:13
TS2314 [ERROR]: Generic type 'ReadableStreamReader' requires 1 type argument(s).
prototype: ReadableStreamReader;
~~~~~~~~~~~~~~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:533:14
TS2314 [ERROR]: Generic type 'ReadableStreamReader' requires 1 type argument(s).
new (): ReadableStreamReader;
~~~~~~~~~~~~~~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:534:11
TS2403 [ERROR]: Subsequent variable declarations must have the same type. Variable 'ReadableStream' must be of type '{ new <R = any>(underlyingSource?: UnderlyingSource<R> | undefined, strategy?: QueuingStrategy<R> | undefined): ReadableStream<R>; prototype: ReadableStream<...>; }', but here has type '{ new (underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number | undefined; size?: undefined; } | undefined): ReadableStream<Uint8Array>; new <R = any>(underlyingSource?: UnderlyingSource<...> | undefined, strategy?: QueuingStrategy<...> | undefined): ReadableStream<...>; prototype: ReadableStrea...'.
declare var ReadableStream: {
~~~~~~~~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:658:13
'ReadableStream' was also declared here.
declare var ReadableStream: {
~~~~~~~~~~~~~~
at asset:///lib.dom.d.ts:12580:13
TS2717 [ERROR]: Subsequent property declarations must have the same type. Property 'closed' must be of type 'Promise<undefined>', but here has type 'Promise<void>'.
readonly closed: Promise<void>;
~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:719:12
'closed' was also declared here.
readonly closed: Promise<undefined>;
~~~~~~
at asset:///lib.dom.d.ts:18811:14
TS2717 [ERROR]: Subsequent property declarations must have the same type. Property 'ready' must be of type 'Promise<undefined>', but here has type 'Promise<void>'.
readonly ready: Promise<void>;
~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:721:12
'ready' was also declared here.
readonly ready: Promise<undefined>;
~~~~~
at asset:///lib.dom.d.ts:18813:14
TS2403 [ERROR]: Subsequent variable declarations must have the same type. Variable 'WritableStreamDefaultWriter' must be of type '{ new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>; prototype: WritableStreamDefaultWriter<any>; }', but here has type '{ new (): WritableStreamDefaultWriter<any>; prototype: WritableStreamDefaultWriter<any>; }'.
declare var WritableStreamDefaultWriter: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:728:13
'WritableStreamDefaultWriter' was also declared here.
declare var WritableStreamDefaultWriter: {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
at asset:///lib.dom.d.ts:18820:13
TS2375 [ERROR]: Duplicate number index signature.
[index: number]: string;
~~~~~~~~~~~~~~~~~~~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:1653:3
TS2717 [ERROR]: Subsequent property declarations must have the same type. Property 'subtle' must be of type 'SubtleCrypto', but here has type 'null'.
readonly subtle: null;
~~~~~~
at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:1749:12
'subtle' was also declared here.
readonly subtle: SubtleCrypto;
~~~~~~
at asset:///lib.dom.d.ts:3749:14
Found 16 errors.
error: Process exited with code 1
I'm using:
→ deno -V
deno 1.8.2
with deployctl installed from:
deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -f https://deno.land/x/deploy/deployctl.ts
Thank you for your help.
I'm not sure this is an issue or it's meant to be like this, but the alias for --version
flag is a capital -V
instead of -v
which seems like a typo.
I can submit a PR to fix it in case it's indeed a typo.
Installing deployctl right now, uses std 0.91.0, yet on master it uses 0.96.0, yet the latest srd version is 0.100.0
i encounter a weird bug in deployctl (i tested using deno 1.9.2 and 1.9.1 and deployctl 0.3.0 on apple M1 and on intel build)
when i run a simple worker like this:
deployctl run --reload --no-check --addr=:8086 script.js
script.js :
self.addEventListener("fetch", (event) => {
event.respondWith(fetch('http://google.com'))
});
every second request to the endpoint hangs and only when i cancel the request client side, then the next request works again and so on.
this only happens if i do the requests from chrome or insomnia, but not with curl as cli, which might point to an issue with connection reuse, i inspected the headers that chrome and insomnia use vs the curl cli ones but could not find a suspicious difference.
the bug could also be reproduced with a different local webserver.
the same behaviour is shown if i use https://deno.land/x/[email protected]/listen.ts with the same worker code, which is a completely different implementation but also uses Deno.serveHttp, so this might point to a bug in deno.
possible connection to: deno issue #10182
When I run locally, everything is OK, but failed on https://deno.com/deploy
TypeError: Blob is not a constructor
at html (https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/libs/serve.ts:33:17)
at https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/main.ts:3:21
at handleRequest (https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/libs/serve.ts:85:20)
at https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/libs/serve.ts:97:27
at innerInvokeEventListeners (deno:op_crates/web/02_event.js:750:27)
at invokeEventListeners (deno:op_crates/web/02_event.js:785:5)
at dispatch (deno:op_crates/web/02_event.js:660:11)
at dispatchEvent (deno:op_crates/web/02_event.js:984:14)
at receiveRequests (deno:js/99_main.js:94:18)
Repo: oyzhen/oyzhen
URL: https://raw.githubusercontent.com/oyzhen/oyzhen/8139bcf20564f8886dad95d8143e0b4b17094c38/main.ts
Hey! I'm trying out Deno Deploy and wanted to connect to a MySQL database, when I important and construct the Client
class from the mysql
third-party package. I get notifified that certain properties don't exists on the Deno instance and that I might want to use the --unstable
flag.
So I figured same old, same old and added --unstable
but this threw an error. After I checked out the help text I noticed that there isn't an option for the unstable flag, Does this mean that it's impossible to run packages that require --unstable
using Deno Deploy? I figure this will cross of alot of packages from being compatible with the hosting service
Reproduction:
import { json, serve } from "https://deno.land/x/[email protected]/mod.ts";
serve({
"/": () => json({ message: "hello world" }),
"api/create": () => json({ message: "created" }, { status: 201 }),
});
Save it as hello.js
and run deployctl run hello.js
. It will show some type conflicts.
error: TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
Using example in https://deno.com/examples/hello.js or any script.
This error is produced by changing the file.
Check file:///mnt/d/code/tmdh-api/$deno$eval.ts
Check data:application/typescript;base64,aW1wb3J0IHR5cGUge30gZnJvbSAiZmlsZTovLy9ob21lL3RhcmVxdWUvLmNhY2hlL2Rlbm8vaHR0cHMvZGVuby5sYW5kLzM4OTc2MjU3OGRmMmE4YWUwYTZkMTg5NWQ1MWFmMTVjY2QxNzFiODEyMTNjYmVmNDQ4NGM0MTQ1MjJmYzE0MmYudHMiO2ltcG9ydCB0eXBlIHt9IGZyb20gImZpbGU6Ly8vaG9tZS90YXJlcXVlLy5jYWNoZS9kZW5vL2h0dHBzL2Rlbm8ubGFuZC9hNTQ4NzNjZTc0NTQ5MTk0MmFiZGU4ODc0YjVlYTkyZjM0M2E5YmU0YTU0MTNlNzhkZmU3Yzk0ZmNmZTJiMjAxLnRzIjtpbXBvcnQgdHlwZSB7fSBmcm9tICJmaWxlOi8vL2hvbWUvdGFyZXF1ZS8uY2FjaGUvZGVuby9odHRwcy9kZW5vLmxhbmQvNzQ2N2JjNzY2Mzg4MGI1MzM5ZjM2ZWUwYWQ2ZGNiY2QzNDljMmI5YzM5NmE0OGI0MDYxNjc5YzNiZWNkMTNiMi50cyI7aW1wb3J0ICJmaWxlOi8vL21udC9kL2NvZGUvdG1kaC1hcGkvaGVsbG8uanMiOw==
Listening on http://0.0.0.0:8080
/mnt/d/code/tmdh-api/hello.js changed. Restarting...
Check file:///mnt/d/code/tmdh-api/$deno$eval.ts
/mnt/d/code/tmdh-api/hello.js changed. Restarting...
error: Uncaught (in promise) BadResource: Bad resource ID
}
^
at deno:core/01_core.js:106:46
at unwrapOpResult (deno:core/01_core.js:126:13)
at opSync (deno:core/01_core.js:140:12)
at Object.close (deno:core/01_core.js:148:5)
at FsWatcher.return (deno:runtime/js/40_fs_events.js:43:12)
at https://deno.land/x/[email protected]/src/subcommands/run.ts:146:2
OS: Linux
Deno version:
deno 1.13.0 (release, x86_64-unknown-linux-gnu)
v8 9.3.345.11
typescript 4.3.5
➜ deployctl deploy --project=testhello ./hello.jsx --no-static
✔ Project: testhello
error: The deployment failed: module with specifier 'file:///src/hello.jsx' not found
According to the docs, Deno.readFile
is available but when I inspect the deployctl.d.ts
file, there's no declaration of it at all
This flag should be used to specify which address to listen on.
url: https://raw.githubusercontent.com/postui/og-image/main/og-image.ts
repo: https://github.com/postui/og-image
deployctl works fine on my computer:
When starting the check
or run
subcommand of the CLI, we should fetch the latest version in the background. When the user exits the application (on "close"
event), we should print out a message if there is a newer version available, like gh CLI does. It should look something like this:
> deno check main.ts
OK
A new release of deployctl is available: 0.2.0 -> 0.3.0
To upgrade, run `deployctl upgrade`
https://github.com/denoland/deployctl/releases/tag/0.3.0
This should only happen if stdin is a tty (Deno.isatty(Deno.stdin.rid)
returns true
).
import { h, jsx, serve} from "https://deno.land/x/[email protected]/mod.ts";
const App = () => (
<div>
<h1>Hello Work!</h1>
</div>
);
const NotFound = () => (
<div>
<h1>Page not found</h1>
</div>
);
serve({
"/": () => jsx(<App />),
404: () => jsx(<NotFound />, { status: 404 }),
});
# deployctl run index.tsx
Check file:///Users/ry/src/deploy-website/$deno$eval.ts
error: TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
interface Account {
~~~~~~~~~
at asset:///lib.dom.d.ts:25:1
Conflicts are in this file.
declare class DOMException extends Error {
~~~~~~~
at file:///Users/ry/Library/Caches/deno/https/deno.land/a54873ce745491942abde8874b5ea92f343a9be4a5413e78dfe7c94fcfe2b201.ts:11:1
however works with
deployctl run --libs=ns,fetchevent index.tsx
Unlike Deploy and the native HTTP bindings in Deno 1.9 and later, deployctl
sets the .body
property to a ReadableStream
even when there is no body. When there is no body, .body
should be set to null
.
I maintain a logging library and like most logging libraries (including std/log
) it imports various colors from /std/fmt/colors.ts
. My library is built to not use colors when they are not available, via Deno.noColor
.
However, when I import my library into a deno deploy script, I get this error when running deployctl check
on it:
error: TS2339 [ERROR]: Property 'noColor' does not exist on type 'typeof Deno'.
const noColor = globalThis.Deno?.noColor ?? true;
~~~~~~~
at https://deno.land/[email protected]/fmt/colors.ts:15:34
Simple reproduction by running deployctl check mod.ts
with mod.ts as follows:
import { blue } from "https://deno.land/[email protected]/fmt/colors.ts";
addEventListener("fetch", (event) => {
const response = new Response("Hello World!", {
headers: { "content-type": "text/plain" },
});
event.respondWith(response);
});
A simple fix would be to set Deno.noColor = false
I believe.
deployctl produces typescript compilation errors when the Error.captureStackTrace
is used along with --libs=ns,fetchevent
(see this for why I am doing this).
deployctl run --libs=ns,fetchevent src/mod.ts
Check file:///Users/kyeotic/dev/brophylactic-bot/$deno$eval.ts
error: TS2339 [ERROR]: Property 'captureStackTrace' does not exist on type 'ErrorConstructor'.
Error.captureStackTrace(errorStack);
~~~~~~~~~~~~~~~~~
at https://raw.githubusercontent.com/discordeno/discordeno/12.0.1/src/rest/run_method.ts:36:9
error: Process exited with code 1
This is related to this deno issue. If its possible to fix this error by including another lib that would solve the issue for me.
When I run the examples in Win10, the terminal says Listening on http://0.0.0.0:8080
This shows 'This site can’t be reached' error in chrome.
If instead I browse to localhost:8080 I get the 'hello world'
Also, http://127.0.0.1:8080 works fine.
deno 1.11.3
deployctl 0.3.0
.
├── index.html
└── mod.ts
mod.ts
:
addEventListener("fetch", (event) => {
event.respondWith(fetch(new URL("index.html", import.meta.url)));
});
deployctl run --no-check mod.ts
Getting the following error when running the above command.
Listening on http://0.0.0.0:8080
error: Uncaught (in promise) TypeError: scheme 'file' not supported
event.respondWith(fetch(new URL("index.html", import.meta.url)));
^
at handleError (deno:core/core.js:186:12)
at jsonOpParseResult (deno:core/core.js:356:9)
at opSync (deno:core/core.js:259:32)
at Object.jsonOpSync (deno:core/core.js:372:12)
at opFetch (deno:op_crates/fetch/26_fetch.js:887:17)
at sendFetchReq (deno:op_crates/fetch/26_fetch.js:1257:44)
at fetch (deno:op_crates/fetch/26_fetch.js:1379:31)
at file:///Users/sr/c/github.com/denoworld/deno.world/dir/mod.ts:8:1
at innerInvokeEventListeners (deno:op_crates/web/02_event.js:750:27)
at invokeEventListeners (deno:op_crates/web/02_event.js:785:5)
error: Process exited with code 1
For example:
> cat repro.ts
function asdf extends Error {}
> deployctl run repro.ts
error: Expected (, got extends at file:///tmp/repro.ts:1:14
error: Uncaught (in promise) SyntaxError: Unexpected end of JSON input
JSON.parse(new TextDecoder().decode(raw)).modules;
^
at JSON.parse (<anonymous>)
at analyzeDeps (https://deno.land/x/[email protected]/src/utils/info.ts:24:10)
at async once (https://deno.land/x/[email protected]/src/subcommands/run.ts:97:17)
at async default (https://deno.land/x/[email protected]/src/subcommands/run.ts:90:21)
at async https://deno.land/x/[email protected]/deployctl.ts:61:13
Like with #34, this crash causes deployctl to exit completely when running with --watch
instead of waiting for a file change to try again.
Problem:
await request.formData()
causes responses to stay pending in Safari and Firefox (and when a redirect is involved, also in Chrome)
Steps to reproduce:
.ts
file and run it, e.g. deployctl run bug.ts
http://localhost:8080
Expected result:
The browser receives a response after form submission.
Actual result:
The browser does not receive a response.
Code:
// bug.ts
const form = `
<form action="" method="post">
<input name="text" type="text" value="Lorem ipsum" />
<button>Submit</button>
</form>
`;
addEventListener("fetch", (event: FetchEvent) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request: Request): Promise<Response> {
if (request.method === "POST") {
const formData = await request.formData();
console.log(formData.get("text"));
return new Response("Go back and try a second time!", {
headers: { "Content-Type": "text/plain" },
status: 200,
});
// Uncomment below (and comment out above) to cause a pending response in all browsers on every form submission
// return new Response(undefined, {
// headers: { Location: "/" },
// status: 303,
// });
}
return new Response(form, {
headers: { "Content-Type": "text/html" },
status: 200,
});
}
Observations:
<input>
element in the formEnvironment:
Firefox 88.0.1 (64-bit)
Safari 14.1 (15611.1.21.161.7, 15611)
Chrome 90.0.4430.212
deno 1.10.2 (release, x86_64-apple-darwin)
v8 9.1.269.27
typescript 4.2.2
When mod.ts
imports nonexistent.ts
:
> deployctl run mod.ts --watch
error: Uncaught (in promise) NotFound: No such file or directory (os error 2)
const watcher = Deno.watchFs(deps);
^
at handleError (deno:core/core.js:186:12)
at jsonOpParseResult (deno:core/core.js:356:9)
at opSync (deno:core/core.js:259:32)
at Object.jsonOpSync (deno:core/core.js:372:12)
at new FsWatcher (deno:runtime/js/40_fs_events.js:13:24)
at Object.watchFs (deno:runtime/js/40_fs_events.js:49:12)
at watch (https://deno.land/x/[email protected]/src/subcommands/run.ts:108:1)
at async default (https://deno.land/x/[email protected]/src/subcommands/run.ts:89:1)
at async https://deno.land/x/[email protected]/deployctl.ts:61:1
Comparatively, deno cache
shows the actual issue:
> deno cache mod.ts
error: Cannot resolve module "file:///work/nonexistent.ts" from "file:///work/mod.ts".
at file:///work/mod.ts:1:0
This is a trivial example, which can be less obvious when refactoring files in a larger project with the watcher running.
Once this module is published to deno.land/x/deploy
, this command should check if any newer versions of the tool are available, and automatically deno install
it over the existing installation.
To include or exclude paths.
Writing automated tests will be easier when we can start and stop the deploy server in Deno code.
Example code:
import {
startServer,
stopServer,
} from "https://deno.land/x/deployctl/runtime.js";
Deno.test("body is hello world", async () => {
startServer(8910);
addEventListener("fetch", (event) => {
event.respondWith(new Response("Hello world"));
});
const response = await fetch("http://localhost:8910");
const body = await response.text();
assertEquals(body, "Hello world");
stopServer();
});
I'm not sure if this would be the best approach to test deploy code. Let me know your thoughts.
(cc @lucacasonato)
Timers have been enabled in Deploy 🎉 we can enable these APIs in deployctl
as well
➜ ~ deployctl --help 2> stderr
➜ ~ cat stderr
deployctl 0.0.1
Run Deno Deploy scripts locally.
To run a script locally:
deployctl run https://deno.land/x/deploy/examples/hello.js
To run a script locally and watch changes:
deployctl run --watch https://deno.land/x/deploy/examples/hello.js
SUBCOMMANDS:
run Run a script given a filename or url
check Perform type checking of the script without actually running it
types Print the Deno Deploy TypeScript declarations
Having the ability to add --env-file .env
would be nice to develop locally
Hi, I am creating a simple blog using pagic and oak with Deno. I can run my code fine locally using deployctl but I get these errors when the code is deployed.
[uncaught oak error]: TypeError - Deno.cwd is not a function
[uncaught oak error]: TypeError - Deno.readDir(...) is not a function or its return value is not async iterable
My code looks as follows:
const app = new Application();
const router = new Router();
router.get("/", async (ctx) => {
let links = [];
for await (const dirEntry of Deno.readDir("public")) {
if (dirEntry.isFile && dirEntry.name.match("^[a-zA-Z]+.[a-zA-Z]+.html$")) {
console.log(dirEntry);
links.push(`<a href="${dirEntry.name}">${dirEntry.name}</a>`);
}
}
ctx.response.headers.set("Content-Type", "html");
ctx.response.body = `
<h1>Blog</h1>
<h5>Example blog using Deno</h5>
<p>Posts:</p>
${links}
`;
});
app.use(router.routes());
// Send static content
app.use(async (context) => {
await context.send({
root: `${Deno.cwd()}/public`,
});
});
addEventListener("fetch", app.fetchEventHandler());
Any help is appreciated.
deploy URL: https://raw.githubusercontent.com/postui/og-image/main/og-image.js
deno.com: https://og-image.deno.dev/hello%20deno%20land
it seems deno.com doesn't allocate enough memory for each request to support CanvasKit in WebAssembly that is used by this case to draw a canvas image output.
Gives a static type error but accessible at runtime as file:///home/nayeem/projects/deno/$deno$eval.ts
. Not a problem with Deploy.
Hey!
Sorry for the shallow post, I'm rather new in the world of Deno.
I've been utilizing deployctl to develop an API service that uses dotenv for storing secret tokens.
Every time i import the library and run deployctl run --libs=ns,fetchevent ./index.ts
I get the following error:
Check file:///Users/user/sites/vilbergs/repo/$deno$eval.ts
error: TS2339 [ERROR]: Property 'readFileSync' does not exist on type 'typeof Deno'.
return parse(new TextDecoder("utf-8").decode(Deno.readFileSync(filepath)));
~~~~~~~~~~~~
at https://deno.land/x/[email protected]/mod.ts:76:55
TS2339 [ERROR]: Property 'errors' does not exist on type 'typeof Deno'.
if (e instanceof Deno.errors.NotFound) return {};
~~~~~~
at https://deno.land/x/[email protected]/mod.ts:78:27
Here is the source repo. The examples above are slightly altered from the source to keep things agnostic to the purpose of my api.
Hello while building my project in GitHub actions for a custom build process I ran in to a problem with deployctl failing if the deployment was trigger on a schedule in GitHub actions
the CD.yaml I use
name: Continuous Deployment
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# every hour
- cron: '0 * * * *'
workflow_dispatch:
jobs:
ci:
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
strategy:
matrix:
os: [ubuntu-latest]
deno-version: [1.20.4]
steps:
- name: Git Checkout Deno Module
uses: actions/checkout@v2
- name: Use Deno Version ${{ matrix.deno-version }}
uses: denolib/setup-deno@v2
with:
deno-version: ${{ matrix.deno-version }}
- name: Run build 👷
run: make build
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: '******'
entrypoint: './main.ts'
Looking at the code why this would happen I didn't came any closer then /deployctl/blob/main/action/index.js
where you start defining the the switch case for the event types. Either the event type has an extra step which is not defined or the API it self gets an type it's confused about.
Here is a build that was triggered on a push that did succeed
Steps to reproduce.
curl https://raw.githubusercontent.com/nonstdout/deno-deploy/main/smiley.png > smiley.png
addEventListener("fetch", (event) => {
event.respondWith(fetch(new URL("./smiley.png", import.meta.url)));
});
curl localhost:8080 > new.png
Try to open the new.png
, and you'll see it being corrupted.
Edit:
Versions: deployctl from main
and deno 1.11.0
We probably can use act for testing our github action in CI
This command should do just a type check of the given module, without actually running it.
deployctl run --watch ./main.js
https://proxyhost.com/test.js
link to the browser.PS: Enter https://proxyhost.com
link to the browser. There is no problem.
main.js
addEventListener("fetch", async (event) => {
const { pathname } = new URL(event.request.url);
if (pathname.startsWith("/test.js")) {
const file = await Deno.readFile("./test.js");
return new Response(file, {
headers: {
"content-type": "application/x-javascript",
},
});
}
const response = new Response("Hello World!", {
headers: { "content-type": "text/plain" },
});
event.respondWith(response);
});
terminal info
Listening on http://0.0.0.0:8080
Http: invalid HTTP method parsed
at deno:core/01_core.js:106:46
at unwrapOpResult (deno:core/01_core.js:126:13)
at async HttpConn.nextRequest (deno:ext/http/01_http.js:64:23)
at async Object.next (deno:ext/http/01_http.js:137:26)
at async handleConn (https://deno.land/x/[email protected]/src/runtime.bundle.js:1425:71)
deployctl version: 0.4.0
Deno version
deno 1.13.2 (release, x86_64-pc-windows-msvc)
v8 9.3.345.11
typescript 4.3.5
http://www.deno.com/ and https://www.deno.com should redirect to https://deno.com/
Currently the DNS isn't set up for www.deno.com
Same thing with www.deno.land
→ deno.land
(This feels like the wrong place to report an issue like this - I just couldn't think of a better one)
would be cool if we could allow github action yaml file to look like this:
- uses: denoland/deployctl@v1
with:
project: example-deno-eleventy
static: _site
instead of:
- uses: denoland/deployctl@v1
with:
project: example-deno-eleventy
entrypoint: https://deno.land/[email protected]/http/file_server.ts
root: _site
I read that I can deploy SPA, but I see that API Reference has no Deno.open
.
deployctl check mode.ts
says the same, and deno.com
as well for such code:
import { urlParse } from 'https://deno.land/x/url_parse/mod.ts';
addEventListener('fetch', (event: FetchEvent) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request: Request) {
const okFile = Deno.open(import.meta.url);
const resultResponse = new Response(null, {
headers: {
body: okFile,
},
});
return resultResponse;
}
Could you please tell me how can I serve static files
, like style
and images
?
EDIT: Maybe related to #20.
This is helpful in monorepos.
I'm not sure if this location is appropriate to open this issue, but it's useful to have a template repository with a GitHub Actions workflow for deployctl already set up, or a starter workflow.
Edit: please don't care. When I created the project, I noticed that I saw a workflow file that I could copy and paste. This is convenient enough.
cc @danopia
I executed from my home directory, my terminal asked for permission to my photos and I denied then this exception was thrown. I assume it's just trying to walk my whole system from the current working directory. The command takes awhile before it even gets to this.
cotyhamilton ~
➜ deployctl deploy --project=clever-dog-43 dev/deno-example/wordle/api/mod.ts
✔ Project: clever-dog-43
⠧ Finding static assets...
error: Uncaught (in promise) PermissionDenied: Operation not permitted (os error 1), readdir '/Users/cotyhamilton/Pictures/Photos Library.photoslibrary'
for await (const file of Deno.readDir(dir)) {
^
at async Object.[Symbol.asyncIterator] (deno:runtime/js/30_fs.js:125:16)
at async walk (https://deno.land/x/[email protected]/src/utils/walk.ts:41:20)
at async walk (https://deno.land/x/[email protected]/src/utils/walk.ts:67:18)
at async walk (https://deno.land/x/[email protected]/src/utils/walk.ts:67:18)
at async deploy (https://deno.land/x/[email protected]/src/subcommands/deploy.ts:153:21)
at async default (https://deno.land/x/[email protected]/src/subcommands/deploy.ts:101:3)
at async https://deno.land/x/[email protected]/deployctl.ts:101:5
It's unfortunate because the install command in the README grants the tool a lot of access.
Because these are not available, I think these shouldn't work in deployctl run
either.
Hi all,
Since I'm not sure where to report this issue, I'll try here.
When I try to link my public github repo, I'm getting following error:
The GitHub repository you are requesting was not found, or you do not have access to view it.
And the screenshot:
I created public repo with such code:
addEventListener("fetch", (event) => {
const resp = new Response("Hello", {
headers: { "content-type": "text/plain" },
});
event.respondWith(resp);
});
deployctl
works well though, but if I want to push to Github deployment is not linked, so I need to manually trigger deployment on dash.deno.com using "Depoy URL" button.
Am I missing something stupid? Or there's a bug right there 🤔
Thank you!
Marko
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.