Don't crash while listing migrations
This commit is contained in:
parent
1f4dd335c5
commit
bde7c576e3
|
@ -1,33 +0,0 @@
|
|||
importScripts('../go_wasm_exec.js');
|
||||
|
||||
/*
|
||||
NOTE(ben): The structure here is a little funny but allows for some debouncing. Any postMessages
|
||||
that got queued up can run all at once, then it can process the latest one.
|
||||
*/
|
||||
|
||||
let ready = false;
|
||||
let inputData = null;
|
||||
|
||||
onmessage = ({ data }) => {
|
||||
inputData = data;
|
||||
setTimeout(doPreview, 0);
|
||||
}
|
||||
|
||||
const go = new Go();
|
||||
WebAssembly.instantiateStreaming(fetch('../parsing.wasm'), go.importObject)
|
||||
.then(result => {
|
||||
go.run(result.instance); // don't await this; we want it to be continuously running
|
||||
ready = true;
|
||||
setTimeout(doPreview, 0);
|
||||
});
|
||||
|
||||
const doPreview = () => {
|
||||
if (!ready || inputData === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = parseMarkdown(inputData);
|
||||
inputData = null;
|
||||
|
||||
postMessage(result);
|
||||
}
|
|
@ -7289,6 +7289,9 @@ hr {
|
|||
border-top-style: solid;
|
||||
max-width: 300px; }
|
||||
|
||||
.mono {
|
||||
font-family: "Fira Mono", monospace; }
|
||||
|
||||
article code {
|
||||
font-family: "Fira Mono", monospace; }
|
||||
|
||||
|
@ -7443,6 +7446,9 @@ article code {
|
|||
.minh-5 {
|
||||
min-height: 16rem; }
|
||||
|
||||
.minh-6 {
|
||||
min-height: 32rem; }
|
||||
|
||||
.fira {
|
||||
font-family: "Fira Sans", sans-serif; }
|
||||
|
||||
|
@ -8004,27 +8010,10 @@ pre {
|
|||
border: 0px solid transparent;
|
||||
/* Not themed */ }
|
||||
|
||||
.editor .toolbar {
|
||||
width: 95%;
|
||||
margin: 10px auto; }
|
||||
.editor .toolbar select {
|
||||
font-size: 10pt;
|
||||
border: 0px; }
|
||||
.editor .toolbar select:hover {
|
||||
border: 0px; }
|
||||
.editor .toolbar select:focus {
|
||||
border: 0px; }
|
||||
.editor .toolbar #bold {
|
||||
font-weight: bold; }
|
||||
.editor .toolbar #italic {
|
||||
font-style: italic; }
|
||||
.editor .toolbar #underline {
|
||||
text-decoration: underline; }
|
||||
.editor .toolbar #monospace {
|
||||
font-family: monospace; }
|
||||
.editor .toolbar #url {
|
||||
text-decoration: underline;
|
||||
font-style: italic; }
|
||||
@media screen and (min-width: 30em) {
|
||||
#preview-container {
|
||||
max-height: calc(100vh - 20rem);
|
||||
overflow: auto; } }
|
||||
|
||||
.edit-form .error {
|
||||
margin-left: 5em;
|
||||
|
|
|
@ -115,13 +115,23 @@ func getCurrentVersion(ctx context.Context, conn *pgx.Conn) (types.MigrationVers
|
|||
return types.MigrationVersion(currentVersion), nil
|
||||
}
|
||||
|
||||
func ListMigrations() {
|
||||
ctx := context.Background()
|
||||
func tryGetCurrentVersion(ctx context.Context) types.MigrationVersion {
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
|
||||
conn := db.NewConn()
|
||||
defer conn.Close(ctx)
|
||||
|
||||
currentVersion, _ := getCurrentVersion(ctx, conn)
|
||||
|
||||
return currentVersion
|
||||
}
|
||||
|
||||
func ListMigrations() {
|
||||
ctx := context.Background()
|
||||
|
||||
currentVersion := tryGetCurrentVersion(ctx)
|
||||
for _, version := range getSortedMigrationVersions() {
|
||||
migration := migrations.All[version]
|
||||
indicator := " "
|
||||
|
|
Loading…
Reference in New Issue