{"id":281295,"date":"2023-09-09T09:00:19","date_gmt":"2023-09-09T01:00:19","guid":{"rendered":"https:\/\/gulass.cn\/?p=281295"},"modified":"2023-08-28T22:38:55","modified_gmt":"2023-08-28T14:38:55","slug":"ben-linux-class","status":"publish","type":"post","link":"https:\/\/gulass.cn\/ben-linux-class.html","title":{"rendered":"Bun 0.8.1 \u7248\u672c\u6b63\u5f0f\u53d1\u5e03\uff0c\u4fee\u590d\u4e0a\u4e00\u7248\u672c\u7684\u95ee\u9898"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nBun v0.8.1 \u7248\u672c\u53d1\u5e03\u3002\u8fd9\u4e00\u7248\u5728 0.8.0 \u53d1\u5e03\u4e00\u5929\u540e\u53d1\u5e03\uff0c\u91cd\u70b9\u4e3b\u8981\u662f\u4fee\u590d\u4e86\u591a\u4e2a\u5b58\u5728\u7684\u95ee\u9898\u548c bug\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u9996\u5148\uff0c\u65b0\u7248\u672c\u89e3\u51b3\u4e86\u4e00\u4e2a\u5f88\u5173\u952e\u7684\u95ee\u9898\uff1a\u5728\u5904\u7406\u683c\u5f0f\u9519\u8bef\u7684\u7248\u672c\u540d\u65f6\uff0cbun install \u4f1a\u5d29\u6e83\u3002\u8fd9\u610f\u5473\u7740\u5982\u679c\u7528\u6237\u8f93\u5165 \"^0.0.2rc1\" \u7b49\u65e0\u6548\u7248\u672c\u6807\u8bc6\u7b26\uff0c\u7cfb\u7edf\u4f1a\u505c\u6b62\u8fd0\u884c\u3002\u5728 Bun v0.8.1 \u4e2d\uff0c\u5f00\u53d1\u8005\u56e2\u961f\u6210\u529f\u5730\u4fee\u590d\u4e86\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f7f\u5f97 bun install \u9762\u5bf9\u8fd9\u7c7b\u8f93\u5165\u4e0d\u4f1a\u518d\u5d29\u6e83\u3002\u8fd9\u5bf9\u4e8e\u7528\u6237\u6765\u8bf4\uff0c\u65e0\u7591\u589e\u52a0\u4e86\u64cd\u4f5c\u7684\u7a33\u5b9a\u6027\u548c\u53ef\u9760\u6027\uff0c\u63d0\u9ad8\u4e86\u6574\u4f53\u7684\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n

\"\"<\/p>\n

\u6b64\u5916\uff0c\u53e6\u4e00\u4e2a\u6bd4\u8f83\u4e25\u91cd\u7684\u95ee\u9898\u4e5f\u5f97\u5230\u4e86\u4fee\u590d\u3002\u539f\u672c\uff0c\u6253\u5305\u5668\u4f1a\u5728\u77e5\u9053\u8fd0\u884c\u65f6\u4f1a\u5931\u8d25\u4e14\u4f4d\u4e8e try\/catch \u5757\u5185\u7684 require() \u8c03\u7528\u65f6\u81ea\u52a8\u5185\u8054\uff0c\u8fd9\u5728\u6253\u5305\u4f7f\u7528\u53ef\u9009\u4f9d\u8d56\u7684\u4ee3\u7801\u65f6\u975e\u5e38\u6709\u7528\u3002\u7136\u800c\u8fd9\u4e2a\u7279\u6027\u88ab\u8bef\u542f\u7528\uff0c\u5bfc\u81f4\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u51fa\u73b0\u8fd0\u884c\u9519\u8bef\u3002\u73b0\u5728\u8fd9\u4e2a\u95ee\u9898\u5df2\u7ecf\u5f97\u5230\u4e86\u4fee\u6b63\uff0c\u5927\u5927\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u8fd0\u884c\u6548\u7387\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n

\u9664\u6b64\u4e4b\u5916\uff0cBun v0.8.1 \u8fd8\u4fee\u590d\u4e86\u5176\u4ed6\u51e0\u4e2a bug\uff0c\u5305\u62ec node:http \u4e2d\u5173\u4e8e\u4ee3\u7406 URL \u7684 bug\u3001bun install \u5904\u7406\u8fc7\u671f package.json \u811a\u672c\u7684\u95ee\u9898\uff0c\u4ee5\u53ca bun --inspect \u4e2d\u6e90\u4ee3\u7801\u6620\u5c04 bug\u3002\u8fd9\u4e9b\u6539\u8fdb\u90fd\u6709\u52a9\u4e8e\u63d0\u5347 Bun \u7684\u6574\u4f53\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n

\u5728\u5f15\u5165\u65b0\u529f\u80fd\u65b9\u9762\uff0cv0.8.1 \u7248\u672c\u65b0\u589e\u4e86\u5bf9 Unix \u57df\u5957\u63a5\u5b57\u7684\u652f\u6301\u3002\u8fd9\u9879\u65b0\u529f\u80fd\u8ba9\u4f60\u53ef\u4ee5\u5c06\u5957\u63a5\u5b57\u6307\u5411\u6587\u4ef6\u7cfb\u7edf\u4e0a\u7684\u6587\u4ef6\uff0c\u800c\u975e\u7f51\u7edc\u4e3b\u673a \/ \u7aef\u53e3\u3002\u8fd9\u5728\u8fd0\u884c\u53ea\u80fd\u4ece\u540c\u4e00\u53f0\u673a\u5668\u8bbf\u95ee\u7684\u670d\u52a1\u5668\u65f6\u5341\u5206\u6709\u7528\uff0c\u5982\u5728\u67d0\u4e9b\u5bb9\u5668\u6216\u4ee3\u7406\u73af\u5883\u4e0b\u3002\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u63d0\u9ad8\u6570\u636e\u4f20\u8f93\u7684\u6548\u7387\u548c\u5b89\u5168\u6027\u3002<\/p>\n

const server = Bun.serve({\r\n  unix: \"\/tmp\/my-socket.sock\", \/\/ <-- new option\r\n  fetch(req){\r\n    console.log(req.url);\r\n    return new Response(\"Hello world!\");\r\n  }\r\n});\r\n\r\nconsole.log(`Listening on unix:\/\/\/tmp\/my-socket.sock!`);<\/pre>\n

\u6027\u80fd\u4f18\u5316\u662f\u8fd9\u6b21\u66f4\u65b0\u7684\u53e6\u4e00\u4e2a\u91cd\u8981\u5185\u5bb9\u3002\u5728 v0.8.0 \u4e2d\uff0c\u5b58\u5728\u4e00\u4e2a\u6027\u80fd\u9000\u5316\u7684\u95ee\u9898\uff0c\u4e8b\u4ef6\u5faa\u73af\u8c03\u5ea6\u5de5\u4f5c\u5f97\u4e0d\u591f\u597d\uff0c\u9020\u6210\u8bfb\u53d6\u8bf7\u6c42\u4f53\u65f6\u672a\u80fd\u53ca\u65f6\u5904\u7406\u5fae\u4efb\u52a1\u961f\u5217\u3002\u4f46\u662f\u5728 v0.8.1 \u4e2d\uff0c\u8fd9\u4e2a\u95ee\u9898\u5f97\u5230\u4e86\u4fee\u590d\u3002\u6d4b\u8bd5\u7ed3\u679c\u663e\u793a\uff0c\u65b0\u7248\u672c\u5904\u7406\u8bf7\u6c42\u7684\u901f\u5ea6\u6bd4 v0.8.0 \u5feb\u4e86 2.8 \u500d\uff0c\u8fd9\u5bf9\u4e8e\u7528\u6237\u6765\u8bf4\uff0c\u5c06\u611f\u53d7\u5230\u660e\u663e\u7684\u901f\u5ea6\u63d0\u5347\u3002<\/p>\n

\u5185\u5b58\u7ba1\u7406\u4e5f\u662f Bun v0.8.1 \u7248\u672c\u8fdb\u884c\u6539\u8fdb\u7684\u5730\u65b9\u3002\u539f\u5148\uff0cHeaders \u548c Blob \u5e76\u672a\u5411\u5783\u573e\u6536\u96c6\u5668\u62a5\u544a\u5b83\u4eec\u7684\u5927\u5c0f\uff0c\u5bfc\u81f4\u5f53 Headers \u6216 Blob \u8db3\u591f\u5927\u65f6\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5783\u573e\u6536\u96c6\u5668\u6ca1\u6709\u5982\u671f\u8fd0\u884c\u3002\u73b0\u5728\uff0cBun \u4f1a\u5411\u5783\u573e\u6536\u96c6\u5668\u62a5\u544a Headers \u548c Blob \u7684\u5927\u5c0f\uff0c\u5e76\u4e14\u6bcf\u6b21\u8c03\u7528 fetch() \u90fd\u4f1a\u5411\u5783\u573e\u6536\u96c6\u5668\u62a5\u544a\u6240\u7528\u5185\u5b58\u3002\u8fd9\u4e00\u6539\u53d8\u5c06\u6709\u52a9\u4e8e\u66f4\u597d\u5730\u7ba1\u7406\u5185\u5b58\u8d44\u6e90\uff0c\u907f\u514d\u56e0\u5185\u5b58\u4f7f\u7528\u8fc7\u5927\u800c\u5f71\u54cd Bun \u7684\u8fd0\u884c\u6548\u7387\u3002<\/p>\n

\u6700\u540e\uff0c\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0cBun 1.0 \u8ba1\u5212\u5728 9 \u6708 7 \u65e5\u53d1\u5e03\u3002\u8fd9\u4e00\u65b0\u7684\u91cd\u5927\u7248\u672c\u5c06\u4f1a\u5e26\u6765\u66f4\u591a\u529f\u80fd\u7684\u6539\u8fdb\u548c\u66f4\u65b0\uff0c\u8ba9\u6211\u4eec\u4e00\u8d77\u671f\u5f85\u5b83\u7684\u5230\u6765\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u9996\u5148\uff0c\u65b0\u7248\u672c\u89e3\u51b3\u4e86\u4e00\u4e2a\u5f88\u5173\u952e\u7684\u95ee\u9898\uff1a\u5728\u5904\u7406\u683c\u5f0f\u9519\u8bef\u7684\u7248\u672c\u540d\u65f6\uff0cbun install \u4f1a\u5d29\u6e83\u3002\u8fd9\u610f\u5473\u7740\u5982\u679c\u7528\u6237 […]<\/p>\n","protected":false},"author":1482,"featured_media":227880,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-281295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/281295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1482"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=281295"}],"version-history":[{"count":6,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/281295\/revisions"}],"predecessor-version":[{"id":281424,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/281295\/revisions\/281424"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/227880"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=281295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=281295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=281295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}